Menu

Arduino Nano error when downloading GCB code

Haroen
2023-04-05
2023-04-22
1 2 > >> (Page 1 of 2)
  • Haroen

    Haroen - 2023-04-05

    Hi,
    I was programming some demo codes and suddenly GCB download window gives errors with my Arduino Nano shown in the jpg.
    The board does give a Windows USB connection sound when plugged in.
    When I try it on another Arduino Nano board it just works fine.

    Does this mean the board has reached it's end of life programming cycle?
    Or is the Arduino Firmware corrupted?

     
  • Anobium

    Anobium - 2023-04-05

    Could be either.

    I would ensure the IDE Programmer Preferences are correct. Specificially, the com port settings.

    Did you check the com port settings? You can use these parameters in Avrudude to validate setup.

    You can reprogram bootloader using a PK2, an UNO.. a host of ways.

     
  • Haroen

    Haroen - 2023-04-05

    Thanks for the quick reply.
    I checked the windows port settings both are on COM8 for the two Nano boards.
    Is there a bootloader programmer option in GCB or hex file available?

     
  • Anobium

    Anobium - 2023-04-05

    Lookup on GitHub for OptiBoot.

    Orm do what I do. Pull the bootloader out of an existing working chip. I know that is working.


    What board is it? I may have one here. Post a photo.

     
  • Haroen

    Haroen - 2023-04-05

    1) Did you mean PK2 is PICKit2 for programming Atmel chip?
    2) Optiboot upgrade is good compatible with GCB?
    3) Pulling the bootloader out of the chip with a Atmel ICE programmer?
    4) Programming the bootloader with a Atmel ICE programmer possible?

     

    Last edit: Haroen 2023-04-05
    • Anobium

      Anobium - 2023-04-05

      1) Did you mean PK2 is PICKit2 for programming Atmel chip? Yes. Works well via AVRDUDE.
      3) Optiboot upgrade is good compatible with GCB? Yes. OptiBoit is likely ti have been the bootloader.
      4) Pulling the bootloader out of the chip with a Atmel ICE programmer? Or, Pk2. Do yu have a spare Nano?
      5) Programming the bootloader with a Atmel ICE programmer possible? Dunno. Never tried.

       
      • Anobium

        Anobium - 2023-04-05

        You make an UNO into STK500 mk1 programmer. That will work.

         
  • Haroen

    Haroen - 2023-04-07

    I have found several video's on internet on how to do it but it did not work.
    I have tried Atmel Studio 7 that now just wouldn't recognize my Atmel-ICE.
    I soldered some headers on another spare Arduino Nano as replacement for now.
    Thank for the help.

     
  • stan cartwright

    stan cartwright - 2023-04-08

    When I connect uno or nano boards to win 10 pc the com port number is always different.
    quote "I checked the windows port settings both are on COM8 for the two Nano boards."

     
  • Haroen

    Haroen - 2023-04-10

    Hai Stan, on my Windows7 the nano boards both pup-up on COM8 for the past month and worked great until one didn't. I will try again some time later but for now I use the replacement Nano.
    I was playing around with code for a gyro sensor and a pressor+temp+humidity sensor when the Arduino Nano died or a coma :-(
    (The sensors is for another topic.)

     
  • Anobium

    Anobium - 2023-04-10

    I did a deep dive into the loss/corruption of the bootloader.

    Being an expert on bootloader, I am, there is always a risk that the self-write operations can actually overwrite the bootloader itself. This risk increases when the user program has data/program in the Progmem last page.

    I have suffered a few bootloader losses of AVR bootloaders when writing a large program. The root cause is highly likely to be a user program and/or a user program & user data that overwrote the bootloader.

    Two things to none.

    GCBASIC compiler does not check if the program exceeds the available progmem space. There is no error condition.
    GCBASIC assumes all the progmem us available - it is not as a portion of the peogmem is where the bootloader resides.

    Two changes

    The latest build of GCBASIC compiler now checks the program does not exceed the available progmem. The compiler now issues a meaningful error message.
    User MUST protect the bootloader by adding a compiler directive to inform the compiler of the progmem size. Use #OPTION RESERVEHIGHPROG 1024 .

    Summary

    Get the latest build 1234, or greater, and, use the compiler directive.

     

    Last edit: Anobium 2023-04-10
  • Haroen

    Haroen - 2023-04-11

    So when we would reach the end of the progmem it would repeatedly overwrite the bootloader ending in more bootloader losses of AVR bootloaders SIP's?
    Good to know that there is now a fail-save build in GCBASIC compiler not to exceed the available progmem space. I tried many demo codes but not sure if I exceeded progmem.

    Two questions on the "Two changes" if I may...

    1) When does the latest build of GCBASIC compiler checks the program not to exceed the available progmem? The compiler now issues a meaningful error message on-the-fly when writing code or at the end when flashing the chip?
    2a) User MUST protect the bootloader by adding a compiler directive to inform the compiler of the progmem size by using #OPTION RESERVEHIGHPROG 1024 for the Arduino Nano only?
    Is this command mandatory for all programs or just for SIP'S chips with bootloader like Arduino and LGT boards?
    2b) Is there a GCBlist of chips progmem?
    I know the "PICInfo Tool" exist for PIC's but for AVR?

     
  • Anobium

    Anobium - 2023-04-11

    Great questions.

    1. The memory check will be issued at the end of compilation. It will therefore prevent the automatic programming of the target chip.

    I could change to delete the hex. This would ensure the errant hex is not used.

    2a. I would add to any chip with a bootloader.

    2b. No, not one that is published. We do need AVRInfo tool. Anyone will to help to pull this together?

     
  • Anobium

    Anobium - 2023-04-11

    Wow... you should preserve 1024 for the AVR bootloader.

    Accordijng to Bard; The ATmega328P has 32KB of program memory, which is also known as flash memory. Of this, 2KB is reserved for the bootloader, leaving 30KB available for user code. The PROGMEM keyword can be used to store data in the remaining 30KB of program memory.

    and, the NANO 2048 for the NANO bootloader

    Bard again: The Arduino Nano X bootloader is 4KB in size. It is stored in the first 4KB of the microcontroller's flash memory. The bootloader is responsible for loading and running the user's sketch. It also provides a number of features, such as the ability to upload sketches over USB.

     
  • Haroen

    Haroen - 2023-04-11

    The only ones with bootloader I know and have, are Arduino Nano, Uno, Mega2560 and the Chinese one LGT8F328P.
    There are a lot others like the ESP32 serie but not GCB relevant/supported.
    Which GCB supported chips are also (frequently) used with a bootloader?

    OptiBoot as Arduino bootloader replacer is an idea to free up more space for progmem:
    Allows larger sketches. Optiboot is only 512 bytes, freeing 1.5k of extra code space compared to older bootloaders.

     
    • Anobium

      Anobium - 2023-04-11

      I always use OptiBoot in UNO, LGT and TBL+ for PICs.

      I always, always extract the bootloader from the board/chip prior to use. And, I retain. If I have an issue I restore.

      From these backups I could examine the size of the bootloader.

      My thoughts from my analysis.

      1024 words for Optiboot non USB, 2048 for OptiBoot with USB support and 128 for TBL.

       
  • Haroen

    Haroen - 2023-04-12

    Just a thought...
    Could the command #OPTION RESERVEHIGHPROG 1024 be something like below instead
    #OPTION RESERVEHIGHPROG OptiBoot
    #OPTION RESERVEHIGHPROG OptiBootUSB
    #OPTION RESERVEHIGHPROG ArduinoNano
    #OPTION RESERVEHIGHPROG ArduinoMega2560
    #OPTION RESERVEHIGHPROG LGT8F328P
    #OPTION RESERVEHIGHPROG TBL+

    Then there is no need for a AVRInfo tool and the last parameter determines how much boatloader memory is hardcoded and how much is free.
    An extra tool for just 6 supported bootloader chips...
    *And where to put the info, in the online help...: 1024 words for Optiboot non USB, 2048 for OptiBoot with USB support and 128 for TBL.

     
    • Anobium

      Anobium - 2023-04-13

      A great idea.

      Is this time to make these change to the compiler yourself ? It is easy.

      The source for the compiler is now installed with your installation. There is an option on GCStudio to edit & compile these sources. And, you can try these ideas in the future.


      The approach to add this new capabiliity.

      1.. Change system.h to have the new constants.

        #DEFINE OPTIBOOT        = 1024
        #DEFINE OPTIBOOTUSB     = 2048
        #DEFINE ARDUINONANO     = 1024
        #DEFINE ARDUINOMEGA2560 = 1024
        #DEFINE TINYBOOTLOADER  = 128
      

      You cannot have + in a constant.

      2.. Add one line of code to the compiler source at line 16814 in gcbasic.bas. The compiler process all #OPTIONs in the method called ReadOptions() in gcbasic.bas.

      The change is very simple, read a line and process it.

      So, change ReadOptions() to substitute a constant when the line equals #OPTION RESERVEHIGHPROG. New line of code CurrElement->Next->Value = ReplaceConstantsLine(CurrElement->Next->Value, 0)

      Build 1237 has this support.

      So, the compiler is very easy to update. And, play with. :-)

       
  • Haroen

    Haroen - 2023-04-15

    I guess that I missed one "TINYBOOTLOADER"...
    And these two I'll try to add...
    #OPTION RESERVEHIGHPROG LGT8F328P
    #OPTION RESERVEHIGHPROG TBL

     
  • Anobium

    Anobium - 2023-04-15

    I have already added .. see https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/lowlevel/system.h

    Lines 117 forward. You need build 1237 or greater for compiler support.


    The LGT is OptiBoot, but, we can more if you think this will help.

     
  • Haroen

    Haroen - 2023-04-18

    Is this time to make these change to the compiler yourself ? It is easy.
    The source for the compiler is now installed with your installation. There is an option on GCStudio to edit & compile these sources. And, you can try these ideas in the future.

    I took a look under-the-GC_hood on the great programming skills of the community!
    My system.h file, even after updating, didn't contain any "#Define Optiboot = 1024".
    How can I update my GCstudio for those changes? (See jpg)

    I still have to edit some SSD1306 Help files from another thread, so I took another look at your previous video .
    That was, as I understand it, somewhat like when I was making websites in the past with asp intelligence where I used Frontpage to build&edit with a CodeScreen and a PreviewScreen.
    I could edit&update directly from my web-server but GCB here I understand that by downloading files first and after edit uploading it for approval is better for inet team-work.

    Help files I think I can handle to edit but under-the-GC_hood code I'll leave that up to professionals of this community although when written I do understand and like to read the code.
    For now I can help by testing and running all kinds of GCBcodes and give ideas (suggestions) on changes.

    The LGT is OptiBoot, but, we can more if you think this will help.

    I think both could work. If someone knows LGT is Optiboot then they write Optiboot and for others they can write LGT.

     
    • Anobium

      Anobium - 2023-04-18

      What build do you have?
      Angel is building 1239 very soon. It will be soon.


      Re the Help. You can grab the ZIP from GitHub and edit in GC Code. There is an extension for ADOC ( called ASCII DOcs) this will show you ADOC source the outcome within GC Code. See https://open-vsx.org/extension/asciidoctor/asciidoctor-vscode but you just install within GC Code.


      Under the hood stuff is a challenge. I iwll document more and more as time goes by.

      But, a great Thank you for helping..

       
  • Haroen

    Haroen - 2023-04-18

    I can't find the "Build" version in the GCstudio Help>>About window.
    (see jpg)

     
  • Anobium

    Anobium - 2023-04-18

    The build info is in the GCStudio/About

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.