​ ​ ​ ​ Reprogramming PICAXE with USB stick - ie FIRMWARE UPDATE
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20

Thread: Reprogramming PICAXE with USB stick - ie FIRMWARE UPDATE

  1. #1
    New Member
    Join Date
    Jun 2015
    Location
    Australia
    Posts
    22

    Lightbulb Reprogramming PICAXE with USB stick - ie FIRMWARE UPDATE

    Hi ALL,

    Hoping to hear from the TOP guru's for this question.

    I am toying with the idea of making an interface for the purpose of updating/reprogramming PICAXE chips with a USB memory stick.

    EG.
    I build a product with a PICAXE as the brains... Ultimately multiple PICAXE chips. Under normal operating conditions, the PICAXE's communicate with one another within the product.

    What would be a supreme benefit would be to be able to send someone a USB memory stick with an updated program/programs on it so they could easily plug the USB stick into the product, turn it on and it automatically updates the PICAXE program/s.



    I can appreciate I will need a USB interface of some sort, but exactly where to start and how to go about it?



    Thanks for your input in advance guru's. Eagerly looking forward to your comments.



    Regards,
    Morty.

  2. #2
    Senior Member
    Join Date
    Feb 2013
    Location
    UK
    Posts
    367

    Default

    Have a look at PICAXE Manual 2; booti2c command. This is the documented method of updating the internal program in a PICAXE chip with a new version. You need to create an interface to hook up an external i2c EEPROM. This will do what you require. I think that interfacing a USB stick is beyond what is possible with PICAXE.

  3. #3
    Senior Member
    Join Date
    Jan 1970
    Location
    Perth, Western Australia
    Posts
    4,306

    Default

    Quote Originally Posted by Circuit View Post
    I think that interfacing a USB stick is beyond what is possible with PICAXE.
    The only way to program a PICAXE from a USB stick would be to put a computer running the programming editor in between the USB stick and the PICAXE

    Quote Originally Posted by Circuit View Post
    Have a look at PICAXE Manual 2; booti2c command. This is the documented method of updating the internal program in a PICAXE chip with a new version. You need to create an interface to hook up an external i2c EEPROM. This will do what you require.
    That option has some merit. The only limitations would be that the PICAXE would run a little slower than one running on internal flash and that you would have to use an X2-series PICAXE.

    In my opinion, if you are going to the trouble of having the client replace an EEPROM chip then for only a slight increase in the overall cost, you may as well exchange the PICAXE chip with a freshly programmed one. Replacing the PICAXE chip would probably be only a small part of the cost if postage and labour are included.

  4. #4
    Senior Member
    Join Date
    Feb 2009
    Location
    Cheshire, England
    Posts
    2,348
    Blog Entries
    4

    Default

    I have a plan that should work.

    1, Build your remote devices with an X2, an I2C EEPROM, and a simple 'serial to USB' board.
    Include an input pin to select a transfer mode. Tie this pin high.

    2, Build your master device with the same components, but tie the input pin low.

    3, Write two transfer routines. One to copy #slot 4 to a file on the USB, and one to copy the file on USB to #slot 4. This second routine ends with a booti2c command.
    Also write a routine to detect the presence of a USB file.

    4, Write your code as normal on the master, including the three routines.
    Arrange the code so that at the start the 'low' pin causes the '#slot 4 to USB' routine to run.
    Arrange that 'USB to #slot 4' is triggered if the pin is 'high' and a USB file is detected. Do this either by default at startup or by polling every few seconds as the code runs, the choice is yours.
    ( At this point the data copied to the USB file will just be whatever is in #slot 4, but we haven't put anything sensible in there yet. )

    5, When you are happy with your master code, download to both #slot 0 and #slot 4.

    6, Run the master.

    Now if it all works as I expect, when the code runs on the master it will copy #slot 4 to the USB, then continue as normal.

    If exactly the same code is initially loaded to a remote device, the 'high' pin will prevent the 'slot to USB' from running, and the code will continue as normal.
    If a USB is detected then the 'USB to #slot 4' is triggered, and the booti2c at the end of the routine causes the code just copied from the USB to #slot4 to execute.

    It's a bit long-winded, but I think it should work.

    ( Note : booti2c does not cause the executed code to run slower, it actually copies the #slot X to #slot 0 before running )

    Cheers,

    Buzby

  5. #5
    Senior Member
    Join Date
    Feb 2011
    Location
    Cardiff,UK
    Posts
    4,196

    Default

    Quote Originally Posted by mortifyu View Post
    I can appreciate I will need a USB interface of some sort, but exactly where to start and how to go about it?
    The question is really, is it even possible ?
    Picaxe in Space is now Silent (but probably still running)
    http://www.50dollarsat.info/

  6. #6
    Senior Member
    Join Date
    Feb 2009
    Location
    Cheshire, England
    Posts
    2,348
    Blog Entries
    4

    Default

    Quote Originally Posted by srnet View Post
    The question is really, is it even possible ?
    Use a simple 'serial to USB' board, like this : http://www.picaxe.com/Hardware/Add-o...logger-Module/

  7. #7
    Senior Member
    Join Date
    Feb 2013
    Location
    UK
    Posts
    367

    Default

    Quote Originally Posted by inglewoodpete View Post

    That option has some merit. The only limitations would be that the PICAXE would run a little slower than one running on internal flash and that you would have to use an X2-series PICAXE.

    In my opinion, if you are going to the trouble of having the client replace an EEPROM chip then for only a slight increase in the overall cost, you may as well exchange the PICAXE chip with a freshly programmed one. Replacing the PICAXE chip would probably be only a small part of the cost if postage and labour are included.
    My understanding of booti2c is somewhat at variance with this; you say that the PICAXE would run slower than one running on internal flash; that is not the case because the program is not run from the EEPROM. Booti2c tests the version of the existing program and the program on the connected EEPROM. If the program on the EEPROM is newer then the existing program is replaced in the PICAXE chip. Therefore, the EEPROM is built into an external and pluggable unit - which could be similar in size to a USB stick - and then used to update the PICAXE program slot when required. It is not left in place, the program is not run from it and it is only used to transfer the updated program to the PICAXE.

    The advantage of this approach is that a simple pinned header or suchlike can be used to attach the updating EEPROM when required; the user is not confronted with the difficulty of changing a PICAXE chip.

    See:http://www.picaxe.com/BASIC-Commands...ation/booti2c/

  8. #8
    Senior Member
    Join Date
    Feb 2013
    Location
    UK
    Posts
    367

    Default

    Quote Originally Posted by Buzby View Post

    3, Write two transfer routines. One to copy #slot 4 to a file on the USB, and one to copy the file on USB to #slot 4. This second routine ends with a booti2c command.
    Also write a routine to detect the presence of a USB file.
    I know of absolutely no way to copy a code from a PICAXE slot out to a file; can I be enlightened?

  9. #9
    Senior Member
    Join Date
    Feb 2009
    Location
    Cheshire, England
    Posts
    2,348
    Blog Entries
    4

    Default

    Quote Originally Posted by Circuit View Post
    ... Therefore, the EEPROM is built into an external and pluggable unit - which could be similar in size to a USB stick - and then used to update the PICAXE program slot when required. ...The advantage of this approach is that a simple pinned header or suchlike ...
    This is a good idea. If you use a USB socket, but wired as I2C, and an EEPROM in a USB stick, it would look to all that it was USB, but it ain't.

    And so much easier to code !.

  10. #10
    Senior Member
    Join Date
    Feb 2009
    Location
    Cheshire, England
    Posts
    2,348
    Blog Entries
    4

    Default

    Quote Originally Posted by Circuit View Post
    I know of absolutely no way to copy a code from a PICAXE slot out to a file; can I be enlightened?
    readi2c : http://www.picaxe.com/BASIC-Commands...acing/readi2c/

    Just read the code from the i2c address corresponding to #slot X byte-by-byte. See booti2c for address details.

    I did it when I thought I was going to need to bypass the booti2c version check, but as it was I didn't need to.

    EDIT : Note, this only works with a slot in an external I2C EEPROM, not with internal slots 0 to 3.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •