Hot!upgrade firmware pic18fxx using USB key

Author
liberte75
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2014/11/18 10:52:13
  • Location: 0
  • Status: offline
2016/03/13 12:52:08 (permalink)
0

upgrade firmware pic18fxx using USB key

I'm developing a new projet with a . I want know if there is any way to upgrade my firmware using a sample USB flash drive. Insert the USB flash in the usb port connected to mu PIC. When I reset the PIC, the new program .hex is transferred to my PIC.
Help me if you have some idea, web site or tutoriels
Thanks
#1

12 Replies Related Threads

    Ian.M
    Super Member
    • Total Posts : 13083
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2016/03/13 12:58:43 (permalink)
    0 (1)
    Cant be done without adding an $expen$ive$ external USB host controller chip as none of the PIC18 on-chip USB SIEs support OTG or Host modes.
     
    OTOH you could write a SPI bootloader that read new firmware direct from a SD card.

    --
    NEW USERS: Posting images, links and code - workaround for restrictions.
    I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
    #2
    liberte75
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2014/11/18 10:52:13
    • Location: 0
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2016/03/13 13:03:53 (permalink)
    0
    Thanks for reply.
    Effectively I found more information how to upgrade firmware using SD card but no information using a standard USB flash memory. 
    #3
    liberte75
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2014/11/18 10:52:13
    • Location: 0
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2016/03/13 13:08:38 (permalink)
    0
    If I change my PIC for a 16bits PIC. There is any possibility to succeed using host controller chip
     
    #4
    Ian.M
    Super Member
    • Total Posts : 13083
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2016/03/13 14:09:13 (permalink)
    +1 (1)
    Sure, any 16 or 32 bit PIC that supports USB OTG can do that using their built in USB SIE.  There are even pre-written bootloader demos available in the MLA.

    --
    NEW USERS: Posting images, links and code - workaround for restrictions.
    I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
    #5
    liberte75
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2014/11/18 10:52:13
    • Location: 0
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2016/03/13 18:06:05 (permalink)
    0
    Can you give me some link please, that contain docs to read or exemple of code. That help me a lot
    #6
    DarioG
    farewell.
    • Total Posts : 53177
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: porcodioland
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2016/03/14 03:04:08 (permalink)

    forget about me, subhumans. adieu

    #7
    BumpSplat
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/11/06 13:23:11
    • Location: 0
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2017/12/05 13:35:16 (permalink)
    0
    I'm in a similar boat.  I'm using a PIC24FJ64GB004.  As I look through the MLA I find interfaces using a File System but it's not clear how to read/extract a binary image from the USB drive after the file has been added using a FAT16/32 computer write operation.  Should/Could I program a USB stick with no file system (using the same processor design in a programmer role) and mail it to the customer?  The concept is clear, the path to doing it isn't.
     
    Thanks to anyone who has info that will help.
     
    Thanks -Tim
    post edited by BumpSplat - 2017/12/05 14:59:21
    #8
    Aussie Susan
    Super Member
    • Total Posts : 2922
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2017/12/05 18:29:58 (permalink)
    0
    You will probably need to modify one of the existing bootloaders. Many assume the input file is a HEX file rather than an image but the principle is the same.
    As for how to trigger off the boot-loading process then that is up to how you want to design it. if your app is normally running and you want to detect when a USB device is inserted, then you will have to put that into your code. Another way is to use a power cycle to reset first to the bootloader which can test if a USB device is present or not.
    I would certainly suggest that you have some way to double-buffer the app code so that you can have the bootloader recover from a failed update - especially if you are not there on site when the upgrade occurs: an easy way to get very angry customers. That requires double the memory for the app plus the bootloader code which all has to fit into the devices 64KB of FLASH memory.
    Susan
    #9
    NKurzman
    A Guy on the Net
    • Total Posts : 15119
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2017/12/05 21:44:57 (permalink)
    0
    For Error Recovery (AKA a non-Bricking Bootloader) with a single image there are several options.
    - If EEPROM is available.  Set a location to indicate the Bootloader succeed.
    - If EEPROM is available is not available.  Set a location Flash  to indicate the Bootloader succeed. 
    - The Reset vector can be set to the Bootloader.  The Real one is saved in RAM until the Bootloader is happy.  (only 99.9% unbrickable)
    - A hardware item that the Bootloader can check.  (like the USB stick)
    - Thas assumes a Bottom Memory Bootloader.
    #10
    BumpSplat
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/11/06 13:23:11
    • Location: 0
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2017/12/06 00:23:45 (permalink)
    0
    Sorry...
    I'm not updating a boot file.  This is a simple language update file used by the embedded system during normal operation.  It's to be retrieved from the drive and stored in EEPROM.  This embedded system doesn't use an OS or File system.  My application, written on C.  
     
    In it's simplest terms, I needing a hex file transported to the field via e-mail or delivered USB stick.
    My question's are:
    - How to translate a FAT16 File from a thumb drive to a hex image I can program into an EEPROM.
    or
    - How to put "into" and "extract" a hex image using a USB Thumb drive.
     
    I'm decent on embedded development but completely new to USB.  I've done a ton of reading MLA documentation but all interaction I see with the drives have been using a file system.  I'd prefer not to go to an OS...  There's my challenge. :)
     
    Thanks - Tim
     
    #11
    Aussie Susan
    Super Member
    • Total Posts : 2922
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2017/12/06 19:09:27 (permalink)
    0
    We are not talking about the bootloader but the app that the bootloader is placing in memory.
    The same comments apply to any part of the app - be it a 'simple language update file' or the whole thing. If there is any sort of error that occurs before getting the bits stored on the device (EEPROM, FLASH or wherever) then it can render the whole app useless. The comments are all about ensuring that the bits in the MCU are those you intend and making sure that the embedded system continues to operate if there is any failure along the way.
    Agreed about the OS and file system - embedded systems very rarely need these.
    Therefore the answers to your questions are: however you design it.
    For a USB thumb drive there are several 'layers' that you will need to consider. Firstly you need to access the USB device (of any sort). For this you could refer to the USB stack from Microchip (or elsewhere) for the low level aspects. You will need to determine what class you want to use - MSC, HID, CDC etc.. USB drives are often MSC and you decision may be driven by what other devices need to communicate with the drive and their limitations.
    Once you are talking to the USB device itself, you then need to think about the format of the information actually on the USB device and how you want to read/write that. Again you may be constrained by what system you use to write the data onto the drive. Form the PC side of things you may be better off using a file system such as FAT16 unless you want to (and can) interact with the USB driver at the required low level. There are FAT16-compatible interfaces for PIC24 (and related) devices around on the internet and from Microchip and these don't use an OS.
    Next comes the format of the data in the file (or whatever) and this is completely up to you: you write it in the first place and need to interpret it in the MCU. As before there are common formats such as Intel HEX around but you can easily make your own (perhaps depending on how much you need to protect your information from your clients).
    Once you have the data then, again, there are many bootloader code examples that you can use to see how to write the data to FLASH, EEPROM or wherever.
    One you break down your problem into its various parts then it is really a case of selecting the code examples/libraries/etc. that are freely available from Microchip, the internet and many other sources.
    Susan
    #12
    NKurzman
    A Guy on the Net
    • Total Posts : 15119
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: upgrade firmware pic18fxx using USB key 2017/12/06 19:25:53 (permalink)
    0
    The File contains Intel Hex formatted Data (not a program for the PIC) that Your Program will read and save the bytes to an EEPROM (On chip or Off). corrent?
    1.The File can be Hex or Bin, Your choice.
    2.Reading from a the Drive will need
    A. The USB MSD Drivers. found in MLA or MCC depending on the chip.
    B. a File System. Available from Microchip, or there are several free ones on the Internet.
     
    If the Data is Intel Hex, you decode it per sample code from a Bootloader, Or, The File Specification.
     
     
    #13
    Jump to:
    © 2017 APG vNext Commercial Version 4.5