;This code does a firmware update on a VM2 via the Flash File System. ;This allows you to update the firmware remotely if you can ; transmit files to the target device. #Define FLASH_WRITE_PROTECT Debug(16) To init ; This ensures internal flash is not write protected ; so that the OS may be reprogrammed. If FLASH_WRITE_PROTECT [ ; Clear write protection - automatically ; resets controller if WP status changed. FLASH_WRITE_PROTECT := 0 ] Make ffs FileSystem("fla") ; Create flash filing system. ; ... ; Your other initialisation code ; ... End To main ; ... update_firmware ; ... End To update_firmware ; You will have to write code to get the new firmware files into ; the Flash File System. This will probably include ; a .VFU Venom Firmware Update file, as well as any fonts, ; bitmaps, sound files, etc that you use. ; The files may be copied across from an SD Card or USB Memory stick ; or sent over the internet, via Ethernet or GPRS ; or transmitted by any other means you can devise. ; (XMODEM can't be used easily because the padding it adds ; corrupts the internal file CRC). ; A VFU file is produced using Protect(4, ...) - see the Help File ; for details. ; Note: it will often make sense to load the .VFU file LAST, as this can ; improve the speed of subsequent updates as files are more likely to remain ; in contiguous blocks. ; To make sure firmware files are in contiguous memory blocks it ; is simplest to delete all the existing files before loading all the new ones. ; However it /may/ be quicker to do this: ; 1. Delete all the files that will be replaced. ; 2. Call FileSystem.Ajust to 'defragment' the file system. ; 3. Load in the new files. ;The above comments are represented by the next three lines: delete_all_files_that_will_be_updated ffs.Adjust ; compact all the files that remain so any new files are contiguous. get_new_firmware_files ; Get the new files. ; We must stop all other tasks while we reprogram the OS. Stop All ; (If this is not the main task then please consult the Help file.) Await Debug(8) = 1 ; Await just one task running. MakeIOSafe ; Place all I/O into a safe state while we reprogram. ; Reprogram the system based on any .VFU file found in the root directory: Protect(3) ; This will reset the controller if reprogramming took place. ; Otherwise it will continue here... ;Deal with situation where no reprogramming took place: Print "No reprog file found, or other error...",CR End