Author Topic: A routine to lock/unlock flash? (Request by Sir, relayed by me)  (Read 8294 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Ok, since SirCmpwn cannot visit any TI site until Summer 2011, I am relaying his request for him:

He would like to ask if someone has a routine to lock/unlock flash memory? He also wants to know which pages would this affect?
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

_player1537

  • Guest
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #1 on: May 12, 2010, 11:14:16 pm »
maybe ask brandon for one, I know he has used it.  But he says it is pretty dangerous iirc

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #2 on: May 13, 2010, 05:19:45 am »
This has been questioned and answered in some UTI topics. mapar007 should have one routine for that and calcmaniac84 probably will (for his TI-Boy SE).

I know he can not visit the TI forums but we can save the pages and send to him. Or see WikiTI ports documentation, I have saw there code to unlock flash.
And Brandon Wilson has the most up to date method to unlock flash (if there is some bcall we can use or details in the instructions to unlock flash) and even knows details in the emulated TI-84+ SE in a Nspire unlock flash.
« Last Edit: May 13, 2010, 05:22:44 am by Galandros »
Hobbing in calculator projects.

Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #3 on: May 13, 2010, 06:11:22 am »
I'll do my duty, then :P

The 'universal exploit' that works on all OS versions. (c) Brandon Wilson

Code: [Select]

UnlockFlash:
;Unlocks Flash protection.
;Destroys: appBackUpScreen
;          pagedCount
;          pagedGetPtr
;          arcInfo
;          iMathPtr5
;          pagedBuf
;          ramCode
        in a,(6)
        push af
        ld a,7Bh
        call translatePage
        out (6),a
        ld hl,5092h
        ld e,(hl)
        inc hl
        ld d,(hl)
        inc hl
        ld a,(hl)
        call translatePage
        out (6),a
        ex de,hl
        ld a,0CCh
        ld bc,0FFFFh
        cpir
        ld e,(hl)
        inc hl
        ld d,(hl)
        push de
        pop ix
        ld hl,9898h
        ld (hl),0C3h
        inc hl
        ld (hl),returnPoint & 11111111b
        inc hl
        ld (hl),returnPoint >> 8
        ld hl,pagedBuf
        ld (hl),98h
        ld de,pagedBuf+1
        ld bc,49
        ldir
        ld (iMathPtr5),sp
        ld hl,(iMathPtr5)
        ld de,9A00h
        ld bc,50
        ldir  
        ld de,(iMathPtr5)
        ld hl,-12
        add hl,de
        ld (iMathPtr5),hl
        ld iy,0056h-25h
        ld a,50
        ld (pagedCount),a
        ld a,8
        ld (arcInfo),a
        jp (ix)
translatePage:
        ld b,a
        in a,(2)
        and 80h
        jr z,_is83P
        in a,(21h)
        and 3
        ld a,b
        ret nz
        and 3Fh
        ret
_is83P: ld a,b
        and 1Fh
        ret
returnPoint:
        ld iy,flags
        ld hl,(iMathPtr5)
        ld de,12
        add hl,de
        ld sp,hl
        ex de,hl
        ld hl,9A00h
        ld bc,50
        ldir
        pop af
        out (6),a
        ret

EDIT:

To answer the second question: unlocking flash enables writing on all pages of the Flash memory (except the boot code, of course), and additionally grants access to the certificate page (7Eh).
« Last Edit: May 13, 2010, 06:13:20 am by mapar007 »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #4 on: May 13, 2010, 09:41:36 am »
OOOH RIGHT! The last part is the one that can be the most dangerous. I think this is what Brandon talked about. When unlocking flash, be VERY careful to not overwrite the certificate, otherwise, big "OOPS".
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #5 on: May 13, 2010, 10:00:32 am »
Yup. But it's hard to do that unintentionally. Brandon screwed up his calc while he was modifying the certificate on purpose, but he messed up endianness and the whole thing failed. => calc bricked (needs 1337 brandon wizardry to unlock :P )

SirCmpwn

  • Guest
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #6 on: May 13, 2010, 03:35:06 pm »
Thanks for the help, but I was hoping for the routine in hex. ;)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #7 on: May 13, 2010, 04:05:18 pm »
What are you going to do with it?
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #8 on: May 13, 2010, 04:28:20 pm »
Thanks for the help, but I was hoping for the routine in hex. ;)
A SirCmpwn drew near? o.o
* DJ Omnimaga hopes he can find easy ways to get on in the future.

He is working on some project that isn't a game but I think it's secret so I can't tell much.

He just need to be VERY careful with that Flash unlocking routine. He should really test on a computer first if he can.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #9 on: May 13, 2010, 05:09:00 pm »
Spoiler For Spoiler:
I can't think of any reason why you'd need to directly write to flash from a user program...
Only an OS should need to do that, in which case you don't need to bother with a hack, since it's your OS.
The only reason for which it could be needed is if you need to create an app directly on-calc. But to do that, you'd have to mess w/the certificate too, and that is just a very bad idea.
Anybody have a better guess?
Edit: Apparently what is above can be construed as rude and careless. I have apologized below. I still feel bad... :(
« Last Edit: May 13, 2010, 05:43:48 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: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #10 on: May 13, 2010, 05:27:48 pm »
I would say why he might need that, but I don't know if I am allowed to do it. I would need his permission first.

I personally do not like when people say things like "why do you need that?" or "why do you want to do that?" when someone asks for a routine or programming help, because it sounds like it implies any use of it would be pointless or that his idea makes no sense or something, while in fact, the programmer may have something special in mind. Why prevent someone from doing something he wants? Plus he might want to keep his ideas secret until he's certain it will work out, anyway.

If everyone cancelled their help requests everytime they got told that in the past, half of the POTY poll choices on ticalc would never have happened. Illusiat 13 would have never been possible, same for Metroid II (the first person to ever want to write a XCOPY/Resource style routine and asked help for it was hit by that question in the past).

All he needs to make sure is to be careful to what he does with the help people provides him.

Let's not get into a "MaxCoderz 2003-04" mentality here
« Last Edit: May 13, 2010, 05:30:50 pm by DJ Omnimaga »
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #11 on: May 13, 2010, 05:39:31 pm »
I was just curious, I'm sorry... :( If I put a damper on anybody's attempts, for goodness's sake, please tell me to stop.
I apologize for anything I may have done. Let me delete that post...
(meh, I feel bad now.)
"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: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #12 on: May 13, 2010, 05:41:23 pm »
I can't think of any reason why you'd need to directly write to flash from a user program...
Only an OS should need to do that, in which case you don't need to bother with a hack, since it's your OS.
The only reason for which it could be needed is if you need to create an app directly on-calc. But to do that, you'd have to mess w/the certificate too, and that is just a very bad idea.
Anybody have a better guess?
Flash unlocking is unusual unless you are writing an OS or patching something.
But he might want only to experiment something, nothing more.

I personally do not like when people say things like "why do you need that?" or "why do you want to do that?" when someone asks for a routine or programming help, because it sounds like it implies any use of it would be pointless or that his idea makes no sense or something, while in fact, the programmer may have something special in mind. Why prevent someone from doing something he wants?
You are right. But sometimes asking why can help can be to give better help or support, not this case, though.
calcdude84se is intrigued and maybe curious. I am curious, too, but I will simply wait for SirCmpwn. :P
« Last Edit: May 13, 2010, 05:43:50 pm by Galandros »
Hobbing in calculator projects.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #13 on: May 13, 2010, 05:46:08 pm »
Well the issue is that the person might not want to reveal anything about his project. If the condition to get help is that he reveals it then it won't work x.x

But yeah just making sure we won't get into a closed-minded mentality about calc development. I still remember the days where if you asked help to do stuff like what Calc84maniac did without revealing your project, you were almost a weirdo x.x, and since Omnimaga activity increased a lot, especially on the ASM side lately, I need to make sure we don't fall back into that mentality so people can still continue progressing in calc dev.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: A routine to lock/unlock flash? (Request by Sir, relayed by me)
« Reply #14 on: May 13, 2010, 06:59:57 pm »
Regardless of what this will be used for, although I think I have an idea, I still say that this is very dangerous.  No one is being close minded here, the routine was already posted that he requested.  We are just discouraging it becasue no one wants to accidentally brick their calculator, you really really have to know what you're doing.  The fact that the routine was asked for in hex makes me think that this is not going to be written in pure assembly.  If that's the case, I would definitely stay away from the flash, there's a lot more to it than just unlocking it.  You still need to swap pages, read things into registers, swap them back into buffers, and other things that really have to be done in assembly.
___Axe_Parser___
Today the calculator, tomorrow the world!