Omnimaga

Omnimaga => News => Topic started by: DJ Omnimaga on July 06, 2014, 06:33:47 pm

Title: ASM arrives on the HP Prime!
Post by: DJ Omnimaga on July 06, 2014, 06:33:47 pm
Partially due to lack of interest from the TI and especially HP community, it will have taken more time than on the Casio PRIZM, but due to HP not having declared war against the community, it will have taken much less time than on the TI-Nspire series. The day where ASM is now possible on the HP Prime has finally arrived!

Quote from: Lionel Debroux
After recently buying a Prime, I've now spent several hours making my own armfir.elf. The result is attached.
The code fills one third of the screen with red, one third with green, and the last third with blue (with some glitches...), then enters an infinite loop. Yeah, this PoC sucks, I know - it sucks just as much as my Nspire DummyOS did, more than three years ago.

Usage: copy the armfir.elf file into APPSDISK.DAT. Firmware transfer, enter recovery mode by pressing the Reset button in the hole on the back, pressing the Symb key, releasing the Reset button, and holding Symb until the Recovery mode screen appears. Then, use usbtool (Windows only).

As usual: works for me, but use at your own risk

Right now, no exploit has been found in the official HP Prime OS by the TI and HP communities, so unlike with Ndless on Nspire OS 3.1 and 3.6, the only current way to run assembly language on the HP Prime is to send a third-party OS to the calculator.

You can download the proof of concept file here (http://www.hpmuseum.org/forum/attachment.php?aid=943).

Although it doesn't do anything much, it still demonstrates how you can install any modified OS on your HP Prime then execute any kind of assembly code in it. Could a patch that can alter the official firmware via Lunar IPS, for example, eventually be made so that ASM launching commands get added? Could the community also be the ones who will fix all the firmware bugs like what happened with the HP 50g? In any case, if anybody decides to learn ARM assembly or C to create advanced softwares for this calculator, remember to stick to recreational, educational and development softwares: programs that can tamper with the HP Prime's exam mode will result into HP blocking third-party and modified firmwares like TI does with Ndless and such programs are against Omnimaga forum rules.

Source:
http://www.hpmuseum.org/forum/thread-1789.html
http://tiplanet.org/forum/viewtopic.php?t=14939
Title: Re: ASM arrives on the HP Prime!
Post by: aeTIos on July 06, 2014, 08:15:56 pm
This pretty much convinced me to buy a Prime. :3 Great work by debrouxl again.
Title: Re: ASM arrives on the HP Prime!
Post by: willrandship on July 06, 2014, 11:28:38 pm
So, what I'm getting from this:

There's no built-in native coding tools, but they have done nothing to stop us from making our own OS with such features built in, even so far as replacing it with an entirely new system.

That is just about the best case scenario.
Title: Re: ASM arrives on the HP Prime!
Post by: Streetwalrus on July 07, 2014, 05:31:44 am
Yes, this is totally awesome. Now I don't just want a Prime, I need a Prime. :P
Title: Re: ASM arrives on the HP Prime!
Post by: DJ Omnimaga on July 07, 2014, 11:01:50 am
So, what I'm getting from this:

There's no built-in native coding tools, but they have done nothing to stop us from making our own OS with such features built in, even so far as replacing it with an entirely new system.

That is just about the best case scenario.
IIRC, they told that as long as we play nice, they'll play nice too. Basically, we need to avoid making programs that can mess around with the calculator teacher mode (eg programs entirely dedicated to cheating in math exams) and we need to ensure that our ASM/C programs cannot easily permanently damage or brick the calculator (but again, the official firmware isn't any better <_<).

In other words, they don't officially support assembly, but they'll give us the freedom to use it as long as we don't tamper with anti-cheating protections. Kinda the same stance as Casio with the PRIZM.
Title: Re: ASM arrives on the HP Prime!
Post by: ordelore on July 07, 2014, 11:37:53 am
So we just need to apply the lessons we learned with the Nspires, and then we have a good time with assembly.
Title: Re: ASM arrives on the HP Prime!
Post by: DJ Omnimaga on July 07, 2014, 11:51:14 am
Indeed, but even then we really need to be careful. Omnimaga forum has rules against cheating tools (assuming they're entirely devoted to cheating) and dangerous programs and I assume it's the same on certain other forums too. It doesn't stop anyone from sneaking such program through torrent trackers, though, either by not caring or purposely wanting to destroy the HP community (eg that one PTTKiller clone program on Github that literally described itself as "community killer"). But again, maybe HP would just force schools to force students to use the latest OS during tests but still allow downgrading for personal use?
Title: Re: ASM arrives on the HP Prime!
Post by: Hayleia on July 07, 2014, 12:02:20 pm
So we just need to apply the lessons we learned with the Nspires, and then we have a good time with assembly.
There is no lesson to get from what happens on Nspires. They are not closed because of a move from the community, they were always closed. Now, I don't say that a program against TI's interest is a good idea, just that even if it contributes to nothing good, it did not start the whole thing either.

Just a question about the HP Prime, would it be possible to "patch" an OS, kind of like what Ndless does ? Because I don't really like the idea of having to choose between HP's OS and the "Ndless" OS.
Title: Re: ASM arrives on the HP Prime!
Post by: Streetwalrus on July 07, 2014, 12:04:04 pm
Well, it is definitely possible. Kind of a romhack actually. :P
Title: Re: ASM arrives on the HP Prime!
Post by: DJ Omnimaga on July 07, 2014, 12:06:46 pm
So we just need to apply the lessons we learned with the Nspires, and then we have a good time with assembly.
There is no lesson to get from what happens on Nspires. They are not closed because of a move from the community, they were always closed. Now, I don't say that a program against TI's interest is a good idea, just that even if it contributes to nothing good, it did not start the whole thing either.

Just a question about the HP Prime, would it be possible to "patch" an OS, kind of like what Ndless does ? Because I don't really like the idea of having to choose between HP's OS and the "Ndless" OS.
Well, I think we still learned a lesson in a way, because the Nspire was closed because of past experiences on the 84+/89 calcs. IIRC, a TI representative mentionned something about MirageOS programs being at risk of bricking the calc (which is impossible with any ticalc program) and cheating (PTTKiller comes to mind). As a result they locked the Nspire down. However, their stupid move was to continue trying to keep it locked down even after the community started playing nice.

I don't know if the OS can be modified directly on-calc. I don't see the issue with an Ndless OS, though, because the author can just make it identical but with an extra ASM command. If HP updates the firmware, then he can apply his changes on the new firmware instead and we're all set. No compatibility issues will occur. The only problem is that the modded OS would need to be an IPS patch that you manually apply to a real OS, to avoid redistributing copyrighted material.


It would be nice if we could dual-boot, though, especially if Linux gets ported to the HP Prime.
Title: Re: ASM arrives on the HP Prime!
Post by: Juju on July 07, 2014, 01:23:15 pm
Yeah, I remember stumbling upon a armfir.elf file when disassembling the OS files, which is probably a standard ELF executable like the ones Linux uses. As I see, Lionel merely replaced it with his own one and it worked. So theorically you can easily replace it with a new third-party OS shell or even the Linux kernel (with the right drivers for the screen, keyboard and such, if they aren't in the kernel already).

Lionel should probably share how he did that (edit: wait, he did! :3), this will surely allow third-party OSes and a C library to be developed like we have on the Casio Prizm. I bet he used a simple GCC compiler for an ARM target, which is easy, but he also figured out how to draw on screen, which I guess is not an easy task.

I can probably try messing up with this, but I have no HP Prime, sadly.
Title: Re: ASM arrives on the HP Prime!
Post by: Streetwalrus on July 07, 2014, 01:28:17 pm
Yeah that Cyrille guy from HP explicitly stated it is a standard elf that you can swap for your own. Also, since it's just that, a custom loader could be made that is run instead of the OS and then runs whatever elf you want it to. Instant multiboot boom. :P
Title: Re: ASM arrives on the HP Prime!
Post by: Juju on July 07, 2014, 01:35:50 pm
Exactly. I'm kind of surprised nobody really bothered to do that until Lionel did, but yeah the hard thing is to figure out the screen and keyboard drivers, that's probably why.

So yeah, as I said, porting the Linux kernel would probably be easy once those drivers figured out and written.
Title: Re: ASM arrives on the HP Prime!
Post by: Streetwalrus on July 07, 2014, 01:37:13 pm
There's even some ground work laid out for that already. The soc is a publicly documented Samsung chip.
Title: Re: ASM arrives on the HP Prime!
Post by: bb010g on July 07, 2014, 01:55:39 pm
AWWW YEAH.  ;D

I am so getting Haskell working on this.
Title: Re: ASM arrives on the HP Prime!
Post by: Streetwalrus on July 07, 2014, 02:16:59 pm
Well, there's an Haskell compiler for arm if I recall correctly. So it's pretty easy. :P
Title: Re: ASM arrives on the HP Prime!
Post by: Princetonlion.tibd on July 07, 2014, 02:25:17 pm
Nice job but sadly I don't have a Prime

(comment)
Title: Re: ASM arrives on the HP Prime!
Post by: ordelore on July 07, 2014, 04:57:04 pm
Wait.
So the experience coding with the Prime will be like coding with pre-TI-83 calculators?
Title: Re: ASM arrives on the HP Prime!
Post by: Juju on July 07, 2014, 05:02:05 pm
The OP is kind of misleading, but it's really C. The coding experience would be comparable to the Casio Prizm.
Title: Re: ASM arrives on the HP Prime!
Post by: Eiyeron on July 07, 2014, 05:03:59 pm
Yeah, C on Prime, now port all the emulators to kill productivity.
Title: Re: ASM arrives on the HP Prime!
Post by: Art_of_camelot on July 07, 2014, 06:38:59 pm
This is pretty awesome. ;D
Title: Re: ASM arrives on the HP Prime!
Post by: Juju on July 07, 2014, 06:40:11 pm
By the way I hacked a little in Lionel's code, I have no idea if it works since I have no HP Prime, but feel free to try it and tell me if it works. Pretty much the same installation instructions as in the OP.

Edit: wait where's the attachment? It says it's there but it's not.

Edit2: http://juju2143.ca/foo_20140707_1831.tar.bz2
Title: Re: ASM arrives on the HP Prime!
Post by: DJ Omnimaga on July 07, 2014, 06:43:29 pm
The OP is kind of misleading, but it's really C. The coding experience would be comparable to the Casio Prizm.
Well, C compiles to some sort of machine code like ASM does and there's no official C compiler dedicated to the Prime, but yeah when ASM is possible on an ARM device, C is automatically possible too.




Also I would try the proof of concept linked in the first post and yours, but I spent $200 with shipping included for that calc and since I often had connectivity problems in the past, I was worried that I could brick my calc or become no longer able to get it detected by my computer. I would rather wait until we have a shell-based example, a way to dual-boot or an OS patch that still provides full official firmware functionalities before taking any risk.
Title: Re: ASM arrives on the HP Prime!
Post by: Juju on July 07, 2014, 06:49:20 pm
I see, but as they said, you can easily go back in recovery mode and go back to the official OS, but yeah there's still a non-null chance to brick it if you mess up. Probably not worth it considering you spent a lot on it.
Title: Re: ASM arrives on the HP Prime!
Post by: DJ Omnimaga on July 07, 2014, 07:53:10 pm
Oh ok, but I was more worried about if an OS file accidentally erased the recovery mode code or something, if that's even possible at all.
Title: Re: ASM arrives on the HP Prime!
Post by: Juju on July 08, 2014, 12:40:08 am
Oh ok, but I was more worried about if an OS file accidentally erased the recovery mode code or something, if that's even possible at all.
I'll just quote the HP Museum thread:
Quote from: debrouxl
Quote from: eried
does the firmware utility always recover the calculator to the "upload" mode?
Holding Symb before and after releasing the Reset button should always be able to recover the calculator, indeed. That is, unless one destroyed the area where the contents of BXCBOOT0.BIN are stored, triggering intentional bricking.
So yeah either you failed bad time with putting the elf in the OS upgrade file so BXCBOOT0.BIN corrupted or said elf messed up with said area where the contents of BXCBOOT0.BIN are stored. Either way, you messed up badly in a specific way if you manage to brick your calc. But normally (someone should confirm it), you should be safe.
Title: Re: ASM arrives on the HP Prime!
Post by: DJ Omnimaga on July 08, 2014, 12:41:53 am
Ah right, so that's the area we must not touch. Beware, ASM/C coders :P
Title: Re: ASM arrives on the HP Prime!
Post by: willrandship on July 08, 2014, 01:28:44 am
@Juju if you can use GCC you have asm readily available. You can even inline it in C code if you want, or you can do pure asm programs.
Title: Re: ASM arrives on the HP Prime!
Post by: Juju on July 08, 2014, 01:33:45 am
@Juju if you can use GCC you have asm readily available. You can even inline it in C code if you want, or you can do pure asm programs.
That is true. There is no C without asm, but the opposite is not always true. ARM processors should always support C.
Title: Re: ASM arrives on the HP Prime!
Post by: willrandship on July 09, 2014, 07:03:14 pm
Agreed. Modern ARM is basically built to run Linux and C.
Title: Re: ASM arrives on the HP Prime!
Post by: timwessman on July 11, 2014, 11:42:45 pm
Minor correction here... I don't think there was anyone not hired or being paid by HP that was fixing or changing anything in the 50g ROM. That was quite a bit before my time, but I am pretty sure that is correct.