This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Technology & Calculator Open Topic subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Community News & Discuss Nspire => Technology & Calculator Open Topic
Author Message
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 04 Mar 2010 02:01:54 am    Post subject:

More questions and observations:

- Does log_rs232() work at all?

- show_dialog_box2() should, I think, take int* arguments (i.e., UTF-32 strings) - not UTF-16 and certainly not char*.

- It would be nice if you added __attribute__((__format__(__printf__,2,3))) to the declaration of sprintf().

- There's a typo in the declaration of stat().

- Any clues on how to use the file I/O functions? Is set_current_path() chdir(), or something more unusual? How do file/directory names used by the file I/O functions map to the user-visible file system? It seems that the initial working directory is not predictable.

- Is there a realloc()?

- Even with -fpic, code generated by GCC isn't truly position-independent (if such a thing is even possible.) I'm not sure how much of an effect -fpic really has on ARM code. At any rate, if you're compiling a C program of any complexity, you're going to need some sort of run-time relocation. I guess this will be eventually be part of the "fully-fledged loader" you mentioned, ExtendeD, but in the meantime, I've been playing around with a quick-and-dirty method for doing so: link the program with two different starting addresses, make a list of where the two binary files differ, add a table to the end of the program, and an assembly stub on the beginning to patch those addresses. This seems to work well enough.
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 04 Mar 2010 08:01:57 am    Post subject:

FloppusMaximus wrote:
- Even with -fpic, code generated by GCC isn't truly position-independent (if such a thing is even possible.) I'm not sure how much of an effect -fpic really has on ARM code. At any rate, if you're compiling a C program of any complexity, you're going to need some sort of run-time relocation. I guess this will be eventually be part of the "fully-fledged loader" you mentioned, ExtendeD, but in the meantime, I've been playing around with a quick-and-dirty method for doing so: link the program with two different starting addresses, make a list of where the two binary files differ, add a table to the end of the program, and an assembly stub on the beginning to patch those addresses. This seems to work well enough.

Use -fpie.
Back to top
ExtendeD


Advanced Newbie


Joined: 30 Aug 2009
Posts: 91

Posted: 04 Mar 2010 05:00:59 pm    Post subject:

FloppusMaximus wrote:
- Does log_rs232() work at all?

You need to:
- re-enable the interrupts with TCT_Local_Control_Interrupts(0). There are currently disabled by the program loader because we have not yet tried to get rid of the clock displayed on the screen (any help on this is appreciated btw).
- Replace/add these lines to os.h (they will be included in the next version of Ndless) :

Code:
#define _log_rs232      (_oscall(void, log_rs232_, const char* msg, void *param2))
#define log_rs232(msg)   (_log_rs232(msg "\n", (void*)log_rs232_param2_))

- Add this line to os_cas_1.1.9170.h :

Code:
#define log_rs232_param2_           0x10522A50

- Add this line to os_1.1.9253.h :

Code:
#define log_rs232_param2_           0x1054EA50


FloppusMaximus wrote:
- It would be nice if you added __attribute__((__format__(__printf__,2,3))) to the declaration of sprintf().
- There's a typo in the declaration of stat().

OK, thanks.

FloppusMaximus wrote:
- Is there a realloc()?

On non-CAS 1.1 : 10181B48 (untested)
We are currently working on populating os.h, but there's much to be done. Many of the libc symbols have already been found for OS 1.7 and are spreaded in the different posts of this topic on yAronet: http://yaronet.com/posts.php?sl=&h=681&s=125502 . Anyone who could find the addresses for OS 1.1 would greatly help.

FloppusMaximus wrote:
- Any clues on how to use the file I/O functions? Is set_current_path() chdir(), or something more unusual? How do file/directory names used by the file I/O functions map to the user-visible file system? It seems that the initial working directory is not predictable.

Many of the stdio.h symbols have already been found for OS 1.7.
calc84maniac also uses NU_ functions for directory listing in his GBC emulator, but finding the following functions would be even better: http://www.opengroup.org/onlinepubs/007908...h/dirent.h.html
Back to top
kaarsten


Newbie


Joined: 12 Nov 2009
Posts: 6

Posted: 04 Mar 2010 05:21:01 pm    Post subject:

Okay, so I still can't get double buffering to work properly. I'm not sure if it's a bug with malloc or a mistake of mine, but even after compiling with flags that get it to compile, the screen just becomes a solid black with garbage pixels in a small area whenever I run the program. Any help? These are the graphics routines.

Code:
unsigned char * VidMem;
unsigned char * BackBuffer;
 
unsigned short ScrW, ScrH;

void InitVideo()
{
   VidMem = ((unsigned char *) SCREEN_BASE_ADDRESS);
   BackBuffer = ((unsigned char *) (malloc(SCREEN_BYTES_SIZE)));
 
   ScrW = SCREEN_WIDTH;
   ScrH = SCREEN_HEIGHT;
 
   /* Switch resolutions if needed... */
   /* Do some more stuff... */
   memset(BackBuffer, 0, (SCREEN_BYTES_SIZE));
}

void SetFBPixel(unsigned short x, unsigned short y, int color)
{
  unsigned char* p = (unsigned char*)(BackBuffer + ((x >> 1) + (y << 7) + (y << 5)));
  *p = (x & 1) ? ((*p & 0xF0) | color) : ((*p & 0x0F) | (color << 4));
}

int GetFBPixel(unsigned short x, unsigned short y)
{
  unsigned char* p = (unsigned char*)(BackBuffer + ((x >> 1) + (y << 7) + (y << 5)));
  return ((x & 1) ? (*p & 0x0F) : (*p >> 4));
}

inline void VideoDown()
{
   free(BackBuffer);
}
void FillBuffer (int color)
{
   memset(BackBuffer, color, SCREEN_BYTES_SIZE);
}
void SwapBuffers()
{
   /* Copy the contents of the back buffer to the front buffer. */
   memcpy(VidMem, BackBuffer, SCREEN_BYTES_SIZE);
}

void BufferInvert(int x, int y)
{
   SetFBPixel(x,y,((GetFBPixel(x,y) ^ 0xFF) & 0x0F));
}
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 04 Mar 2010 09:14:15 pm    Post subject:

calc84maniac wrote:
Use -fpie.

Yes, I tried that; no, it doesn't work. I assume that both -fpic and -fpie are depending on the C library and/or OS to actually do the work of relocating the program.

By the way, as a general matter, it would be better for the system routines to be defined as normal C functions, with the locations supplied by a library, rather than defining them as complicated macros in the header files.


Last edited by Guest on 04 Mar 2010 09:57:36 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 04 Mar 2010 10:46:52 pm    Post subject:

FloppusMaximus wrote:
calc84maniac wrote:
Use -fpie.

Yes, I tried that; no, it doesn't work. I assume that both -fpic and -fpie are depending on the C library and/or OS to actually do the work of relocating the program.

By the way, as a general matter, it would be better for the system routines to be defined as normal C functions, with the locations supplied by a library, rather than defining them as complicated macros in the header files.

It stands for Position-Independent Executable, and executables generated by it should work wherever they are loaded. Trust me, that's what I use.
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 04 Mar 2010 11:01:35 pm    Post subject:

What do you use for an ld script? What libraries?

Last edited by Guest on 04 Mar 2010 11:07:18 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 04 Mar 2010 11:44:54 pm    Post subject:

FloppusMaximus wrote:
What do you use for an ld script? What libraries?

None whatsoever. I did all this before Ndless was released.
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 05 Mar 2010 01:47:52 am    Post subject:

Then perhaps it would help if you'd describe exactly what steps you're taking to compile and link the program. You are using GCC and the GNU binutils, -arm-elf versions, correct? What do you do for startup code, and what are you doing to convert the output to a tns file?

Here is a simple example of something that fails if you're not doing run-time relocation:

Code:

const int arr[] = { 123, 456, 789 };

const int *p = arr;

int main()
{
  char b[256];
  int wb[256], i;

  sprintf(b, "p = %x\narr = %x\np[0] = %d",
     (unsigned int) p, (unsigned int) arr, p[0]);

  for (i = 0; b[i]; i++)
    wb[i] = b[i];
  wb[i] = 0;
  show_dialog_box2(0, (void*)L"Hello", (void*)wb);
}
Back to top
Lego


Advanced Newbie


Joined: 05 Feb 2010
Posts: 58

Posted: 05 Mar 2010 11:08:57 am    Post subject:

Well, how does this RunOS code work?
http://www.mirari.fr/U2wd
Does it the same as the boot code, copy the os to ram and boot it?

This would be interesting for all who need to use 1.7 Sometimes, because upgrading, downgrading and cracking again with ndless just won't be good for the flash.
Maybe you could release this tool with an if request that prevents running cas on an non cas?
Back to top
ExtendeD


Advanced Newbie


Joined: 30 Aug 2009
Posts: 91

Posted: 05 Mar 2010 11:56:16 am    Post subject:

FloppusMaximus wrote:
Here is a simple example of something that fails if you're not doing run-time relocation

-fpic/-pie unfortunately doesn't guarantee position-independent code (see http://ti.yaronet.com/posts.php?sl=&s=...9&h=562#562 in French ).
static data will generate a GOT table, which should be relocated by an executable loader.

Lego wrote:
Well, how does this RunOS code work?
This would be interesting for all who need to use 1.7 Sometimes, because upgrading, downgrading and cracking again with ndless just won't be good for the flash.
Maybe you could release this tool with an if request that prevents running cas on an non cas?

We are currently thinking about such an OS loader.
Back to top
ZagorNBK


Newbie


Joined: 29 May 2008
Posts: 36

Posted: 05 Mar 2010 02:31:29 pm    Post subject:

Yeah, but having CAS on the non-CAS version would be cool. I don't think that this will be considered very illegal since TI proposes itself to download the OS on their site.
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 05 Mar 2010 03:12:59 pm    Post subject:

ZagorNBK wrote:
Yeah, but having CAS on the non-CAS version would be cool. I don't think that this will be considered very illegal since TI proposes itself to download the OS on their site.

But you are only supposed to use it on the calculator that you paid extra money for a CAS. Remember, much of what you pay for their calculators is the OS -- always has been that way.
Back to top
Lego


Advanced Newbie


Joined: 05 Feb 2010
Posts: 58

Posted: 05 Mar 2010 03:31:53 pm    Post subject:

calc84maniac wrote:
ZagorNBK wrote:
Yeah, but having CAS on the non-CAS version would be cool. I don't think that this will be considered very illegal since TI proposes itself to download the OS on their site.

But you are only supposed to use it on the calculator that you paid extra money for a CAS. Remember, much of what you pay for their calculators is the OS -- always has been that way.


Or any other Problems for TI, because from this day the TI without CAS is not allowed in schools and exams whey are designed for non cas calculators.
Edit: its also a Problem for you, if this becomes public and the numeric ti isn't allowed, you have to buy an other calculator and learn how to use it.
There must be such an OS loader, but the basic version should just load the non cas os. Just an "extended" loader for CAS should load both.

Well if you smart enough you could take the extended loader for cas, de and recompile it for the numeric. This probably won't be a problem because this won't be public. The real problem is if you just use an cas during an non cas exam you cheat.


Last edited by Guest on 05 Mar 2010 03:44:55 pm; edited 1 time in total
Back to top
IAmACalculator
In a state of quasi-hiatus


Know-It-All


Joined: 21 Oct 2005
Posts: 1571

Posted: 06 Mar 2010 09:05:20 am    Post subject:

Yeah. We don't want to cost TI millions by getting their non-CAS calculators banned, as much as we dislike them at times.
Back to top
Techrocket9


Advanced Newbie


Joined: 07 Nov 2009
Posts: 62

Posted: 06 Mar 2010 08:49:10 pm    Post subject:

Lego wrote:
calc84maniac wrote:
ZagorNBK wrote:
Yeah, but having CAS on the non-CAS version would be cool. I don't think that this will be considered very illegal since TI proposes itself to download the OS on their site.

But you are only supposed to use it on the calculator that you paid extra money for a CAS. Remember, much of what you pay for their calculators is the OS -- always has been that way.


Or any other Problems for TI, because from this day the TI without CAS is not allowed in schools and exams whey are designed for non cas calculators.
Edit: its also a Problem for you, if this becomes public and the numeric ti isn't allowed, you have to buy an other calculator and learn how to use it.
There must be such an OS loader, but the basic version should just load the non cas os. Just an "extended" loader for CAS should load both.

Well if you smart enough you could take the extended loader for cas, de and recompile it for the numeric. This probably won't be a problem because this won't be public. The real problem is if you just use an cas during an non cas exam you cheat.



The only benefit of nonCas on CAS would be 84 mode, which requires an 84 keypad. The only cross-OS-ing of note would be CAS on a not. I own both calculators, so that would be fine by me (having to only carry one.)
Back to top
bwang


Member


Joined: 15 Mar 2009
Posts: 128

Posted: 07 Mar 2010 12:59:36 am    Post subject:

The difference in the prices of the CAS and non-CAS is pretty trivial. TI's main worry would be this calculator getting banned on the tests such as the ACT, which do not allow CASes.

Maybe the loader could be open source, with the default binary doing checking for the CAS OS. Anyone who is clever enough can comment out the checks in the source and recompile. This would stop the average user (a non-programmer) from installing the CAS on their non-CASes, so long as no one releases modified versions or instructions on how to modify it (we assume everyone skilled enough to modify the source is also considerate enough not to risk destroying the Ndless project).
Back to top
Lego


Advanced Newbie


Joined: 05 Feb 2010
Posts: 58

Posted: 07 Mar 2010 01:00:29 pm    Post subject:

You don't need the source to comment out the check, if you are clever enough you can remove the check from the binary Very Happy
Back to top
bwang


Member


Joined: 15 Mar 2009
Posts: 128

Posted: 07 Mar 2010 06:55:42 pm    Post subject:

Agreed, but then I'd have to be cleverer than I actually am Sad
Back to top
ExtendeD


Advanced Newbie


Joined: 30 Aug 2009
Posts: 91

Posted: 08 Mar 2010 02:17:56 pm    Post subject:

The Subversion Trunk (latest source code) of Ndless is now publicly available, for those interested by the unreleased work: https://www.unsads.com/scm/svn/nsptools/Ndless/trunk/ , guest/guest (you can accept the certificate)
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
» View previous topic :: View next topic  
Page 2 of 7 » All times are UTC - 5 Hours

 

Advertisement