Page 1 of 1

How to modify NXT Firmware

Posted: 12 Mar 2012, 14:50
by ricardocrl
Hello all,

I've been searching on how to modify, compile and get the .rfw firmware to flash.

I have one first basic question. If I don't need to debug, do I need to open any hardware and install the JTAG connector?

I thought I only needed to install the IAR Embedded Workbench, edit the source code, compile and flash a new .rfw. Am I wrong about this?

Thanks for any help!
Ricardo

Re: How to modify NXT Firmware

Posted: 12 Mar 2012, 15:25
by afanofosc
All you need to do is exactly what you describe, except that you get a .a79 file rather than a .rfw file. I have a simple tool that pads the .a79 file to the full 256k and saves it as a .rfw file. You can flash a .a79 file to the NXT using BricxCC without any problems. It overwrites just the code portion of the existing firmware and leaves the remainder of the flash memory untouched (i.e., the part where you have files stored).

Can you describe what you have in mind in terms of modifying the firmware?

John Hansen

Re: How to modify NXT Firmware

Posted: 12 Mar 2012, 15:42
by ricardocrl
Hello John,

Thanks a lot! That would be exactly my next question, because I tried doing "make", but couldn't find the .rfw file. ;)

Well, my intention is to provide an automatic passkey when a bluetooth request happens. The goal is to skip the manual pairing process. It is a quite specific implementation, since I believe it is safer to request a manual insertion of the pass-key (at least for safety reasons).

The idea is not pairing between NXTs, but pairing from a computer. What I want to develop is for someone "non-engineering" related to use. I am trying to understand what strange BT things can happen and try to avoid them. The pairing is one of them. Once in a while, the BT dongle software on the PC side (or the windows drivers) removes devices that were paired before, I don't know why. If, when starting the application, it pairs the NXTs without manual help, the user wouldn't have to bother.

Do you see any constraints on my desired implementation? (I think I already found the portion of code to change)

Ricardo

Re: How to modify NXT Firmware

Posted: 12 Mar 2012, 20:09
by mrblp
Hello,
ricardocrl wrote:The idea is not pairing between NXTs, but pairing from a computer. What I want to develop is for someone "non-engineering" related to use.
You can do that. But remember that you cannot change the code on the computer so easily. Such a "one side pairing" may confuse anyone, not just engineers. Because it is well known for anyone using BT that the devices have to be paired.
I am trying to understand what strange BT things can happen and try to avoid them. The pairing is one of them. Once in a while, the BT dongle software on the PC side (or the windows drivers) removes devices that were paired before, I don't know why.
You should try to change the latter and not change the firmware. The fact that the MAC address is bound to the BT stick explains why you get in trouble when using the stick on different computers with the same devices.

The secret key to connect the device is stored on the computer with the devices MAC address assigned and is stored on the device with the sticks MAC address assigned. When connected to another computer with the same stick the computer finds a new device with a MAC address so it starts the pairing process. The device gets a new pairing process for the stick with its (same) MAC address. So the secret key of the first pairing process will be overwritten in the device. When trying to connect the device with the same stick to the first computer that computer will deny the new secret key - it does not match the stored one.

The secret key is not 1234 - just for your information. It is a calculated key nearly random at every pairing process.

I hope my english is well enough...
afanofosc wrote:I have a simple tool that pads the .a79 file to the full 256k and saves it as a .rfw file.
You can get the same by setting up the linker options to fill the remaining memory with 0xff... Then there is a simple rename process left ;-)

Bye marvin

Re: How to modify NXT Firmware

Posted: 13 Mar 2012, 00:42
by tcwan
mrblp wrote:Hello,

The secret key to connect the device is stored on the computer with the devices MAC address assigned and is stored on the device with the sticks MAC address assigned. When connected to another computer with the same stick the computer finds a new device with a MAC address so it starts the pairing process. The device gets a new pairing process for the stick with its (same) MAC address. So the secret key of the first pairing process will be overwritten in the device. When trying to connect the device with the same stick to the first computer that computer will deny the new secret key - it does not match the stored one.

The secret key is not 1234 - just for your information. It is a calculated key nearly random at every pairing process.

Bye marvin
There is actually a way using regedit to copy the secret key from one computer to another so that after successfully pairing to one PC, you can use the same pairing on the other. Of course, that would be messy if both PCs are active and within range at the same time!

Sorry I can't find the exact information offhand. The best I googled is this: http://www.seguridadmobile.com/bluetoot ... nisms.html. I had to solve this problem to use a BT mouse between Mac OSX and Win for Bootcamp (dual booting on Mac).

Re: How to modify NXT Firmware

Posted: 13 Mar 2012, 10:45
by ricardocrl
Thank you both for the tips. Actually, I won't run into that problem, because the dongle and the computer will always be the same, with no change.

Apparently the NXTs get unpaired sometimes (rarely, I must say, but it happens), using the same PC, same dongle, no new pairings in the meanwhile, nothing that could affect, I thought.
mrblp wrote: You can do that. But remember that you cannot change the code on the computer so easily. Such a "one side pairing" may confuse anyone, not just engineers. Because it is well known for anyone using BT that the devices have to be paired.
It is not a big deal to pair them first. I think I can just skip pairing, by software if I detect that the NXT is already paired (thinking of Fantom drivers API).