Author Topic: OS Programming  (Read 6244 times)

0 Members and 3 Guests are viewing this topic.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
OS Programming
« on: May 16, 2010, 09:02:11 pm »
I feel like starting an OS. It probably won't get far, but there are a few things I felt I needed to ask.
From what pages can protected ports be accessed? (like flash unlocking, etc.)
What flash pages must contain what? what can't be touched?
Where can I find documentation on accessing flash?

Thanks for any help.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: OS Programming
« Reply #1 on: May 16, 2010, 09:20:24 pm »
I'm fairly sure BrandonW's wiki page has a lot of that information. I'm not sure though, I was just looking at it yesterday.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: OS Programming
« Reply #2 on: May 17, 2010, 07:50:20 am »
All it has that I can use is the port documentation, which is good, but I need to know how to use flash (my main concern)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: OS Programming
« Reply #3 on: May 17, 2010, 09:41:29 am »
For written documentation you can have luck in WikiTI, ask Brandon Wilson and as last resource, see the source code of some 3rd party OS (maybe some source code is well documented and explains what you want).

At least have fun with the experiment. ;)
« Last Edit: May 17, 2010, 09:43:02 am by Galandros »
Hobbing in calculator projects.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: OS Programming
« Reply #4 on: May 18, 2010, 07:09:57 pm »
C/O buckeyedude, I got the model nos. of the flash chips and found the docs for them.
Once I finish laying out the FS design and how various other things will work, I get to start programming this thing. 8)
« Last Edit: May 18, 2010, 07:10:44 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: OS Programming
« Reply #5 on: May 18, 2010, 08:11:05 pm »
I missed this topic

A new OS would be cool, but if it doesn't support dual-booting or lacks any add-on/module including all essential hi school (and optionally, College) math functions, then the OS audience will be much smaller, because most people will stick to the official OSes for school. This is why few people use Ndless: they need to use an OS lacking most functions they need in math.

Otherwise, I would love to see a new OS that allows for development for low and hi level programmers

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: OS Programming
« Reply #6 on: May 18, 2010, 08:19:18 pm »
As said on IRC, I plan to make it modular. I'll look into dual-booting later (I'll try to make the code flexible enough to support it in the future). I'm probably not going to implement anything beyond basic math myself. I may implement a compat layer eventually.
As soon as I have a working alpha, I'll give this thing its own topic.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: OS Programming
« Reply #7 on: May 21, 2010, 10:25:12 pm »
I'm stuck. How does dual booting work? I can't seem to figure it out...
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: OS Programming
« Reply #8 on: May 21, 2010, 10:29:25 pm »
Mhmm I think BrandonW's OS2 project supports dual-booting, so he might be able to awnser you. I'll grab his attention for this topic.

Offline BrandonW

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +38/-1
    • View Profile
Re: OS Programming
« Reply #9 on: May 21, 2010, 11:57:52 pm »
I feel like starting an OS. It probably won't get far, but there are a few things I felt I needed to ask.
From what pages can protected ports be accessed? (like flash unlocking, etc.)
What flash pages must contain what? what can't be touched?
Where can I find documentation on accessing flash?

Thanks for any help.

Protected ports can be read from and written to from "privileged" pages or sectors, which include pages: 2Fh/6Fh, 1Ch/3Ch/7Ch, 1Dh/3Dh/7Dh, 1Fh/3Fh/7Fh.
Flash page 00 is permanently fixed in the first bank, or address range 0000h to 3FFFh, so it must contain the boot sequence at 0053h, OS valid markers at 0026h (if memory serves) and 0056h, and the interrupt at 0038h (if your OS has an interrupt, which it almost certainly will).
The boot code, or more accurately the boot sectors, cannot be modified. They include 1Fh/3Fh/7Fh on all models and additionally 2Ch/6Ch to 2Fh/6Fh on the 84+/SE.
The certificate area is Flash page 1Eh/3Eh/7Eh and it's highly recommended that you never touch this Flash page as it's a data-only page, contains calculator-specific information such as the calculator ID and license updates, Press-to-Test/Testguard2/Flash application bitmaps, and other stuff. Corrupting this area of memory also has the potential to permanently brick a graphing calculator (the only known way to do so through software).

You can find documentation on accessing the Flash chip from the chip documentation, WikiTI, and PongOS, though quite frankly, it's not really necessary -- the boot code already has routines that wrap this stuff up for you, such as _WriteFlashUnsafe, _EraseFlash, etc.

I'm stuck. How does dual booting work? I can't seem to figure it out...

There is no standard for dual booting. The only known third-party OS to do it is OS2, and its method is rather involved.

Because OS2 only uses six pages, 00h to 03h and 7Ch to 7Dh, and because there are six pages of Flash memory not currently in use by any OS (pages 6Ah, 6Bh, and 70h to 73h), OS2 can store six pages of itself and the six pages shared with the TI-OS. By swapping between pages 00h-03h and 7Ch-7Dh and the unused pages, it can get away with dual booting. (Note this doesn't apply to the 73 or 83+, which don't have a sector 70h -- they don't have enough space for dual booting and so it's not supported on those.)

The actual swap is fairly trivial -- back up the first sector (pages 00h to 03h) to the swap sector (typically 08h, but can be 0Ch or frankly any sector that starts with byte 0FEh), erase the first sector, copy the unused sector (pages 70h to 73h) to the first sector, erase the unused sector, and copy the swap sector to the unused sector. Then do the same thing involving pages 7Ch-7Dh and 6Ah-6Bh (which is a little trickier since it shares a sector with the beginning of Flash application space (68h-69h)).

To make the swap possible oncalc, there is a specific key sequence you hold on boot. On OS2, this is [ON]+[X,T,theta,n]. Part of OS2's startup sequence is to check for this key combination, and if detected, present a "Switch OS?" menu and do the above.
The problem here is that the TI-OS also needs this key sequence, which requires patching its startup sequence (at 0053h) to check for the key combination, and if not pressed, boot normally, otherwise present the same menu as above.

After OS2 is installed on a calculator, you can place it in a special mode to receive a copy of the TI-OS. This works like a typical OS transfer, except instead of writing the data from pages 00h-03h and 7Ch-7Dh to the actual pages, it writes them to the extra Flash pages instead. It also patches page 0 in memory to include the [ON]+[X,T,theta,n] check.

Needless to say, dual booting is an advanced feature, as is writing an OS at all, so I highly recommend taking your time and not getting discouraged. It's quite literally the largest calculator project you can undertake, and no one has ever successfully completed it.

Hope that helps.

EDIT: By the way, sector 70h is explicitly checked by the OS to make sure it's empty, and if not, it erases it. This check is also patched out of the TI-OS by OS2 when it receives it.
And also, the SVN repository of the source is at http://brandonw.net/svn/calcstuff/OS2/ if you want to see this nightmarish stuff for yourself.
« Last Edit: May 22, 2010, 12:40:05 am by BrandonW »

Offline Silver Shadow

  • Beta Tester
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +27/-7
    • View Profile
Re: OS Programming
« Reply #10 on: May 22, 2010, 03:05:18 am »
Speaking of OS2, how is it going along? Any new features planned/done ?
Former Coder of Tomorrow


Offline BrandonW

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +38/-1
    • View Profile
Re: OS Programming
« Reply #11 on: May 22, 2010, 03:08:01 am »
Speaking of OS2, how is it going along? Any new features planned/done ?

No, because one or two larger projects with deadlines have to take precedence. As soon as they're done, I'll get back to OS2.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: OS Programming
« Reply #12 on: May 22, 2010, 05:34:53 pm »
Speaking of OS2, how is it going along? Any new features planned/done ?

No, because one or two larger projects with deadlines have to take precedence. As soon as they're done, I'll get back to OS2.

I can't wait to see what you'll come up with

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: OS Programming
« Reply #13 on: May 22, 2010, 06:28:49 pm »
Speaking of OS2, how is it going along? Any new features planned/done ?

No, because one or two larger projects with deadlines have to take precedence. As soon as they're done, I'll get back to OS2.

How's your secret project coming along?

Offline BrandonW

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +38/-1
    • View Profile
Re: OS Programming
« Reply #14 on: May 22, 2010, 06:30:53 pm »
Slowly.