Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-29 Thread via GitHub


acassis closed issue #16444: [BUG] ATMega2560 USART0 not working
URL: https://github.com/apache/nuttx/issues/16444


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-27 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2914913102

   If I change the linker script such that:
   
   ```ld
   .data:
   {
   _sdata = ABSOLUTE(.);
   *(.rodata .rodata.*)
   *(.data .data.*)
   *(.gnu.linkonce.d.*)
   CONSTRUCTORS
   _edata = ABSOLUTE(.);
   } > sram AT > flash
   
   _eronly = LOADADDR(.data);
   ```
   
   ```diff
   diff --git a/boards/avr/atmega/arduino-mega2560/scripts/flash.ld 
b/boards/avr/atmega/arduino-mega2560/scripts/flash.ld
   index f365646dfa..73a62017ed 100644
   --- a/boards/avr/atmega/arduino-mega2560/scripts/flash.ld
   +++ b/boards/avr/atmega/arduino-mega2560/scripts/flash.ld
   @@ -122,7 +122,6 @@ SECTIONS
_etext = . ;
} > flash

   -_eronly = ABSOLUTE(.);

.data:
{
   @@ -134,6 +133,8 @@ SECTIONS
_edata = ABSOLUTE(.);
} > sram AT > flash

   +_eronly = LOADADDR(.data);
   +
.bss:
{
_sbss = ABSOLUTE(.);
   ```
   
   I am able to boot into NSH. It appears the initializer data for the 
variables loaded to SRAM from FLASH is not actually getting stored in flash in 
the image.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-27 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2914818143

   It does seem to be a memory issue as suggested by KR, attempting to print a 
string like so:
   
   ```c
   static char static_str[] = "hello from static";
   for (int i = 0; i < sizeof(static_str) / sizeof(char); i++)
   {
 up_putc(static_str[i]);
   }
   ```
   or like so
   ```c
   char stack_str[] = "hello from stack";
   for (int i = 0; i < sizeof(stack_str) / sizeof(char); i++)
 {
   up_putc(stack_str[i]);
 }
   ```
   Fails. In fact, I can see it run into some string in memory and start 
printing that forever instead:
   ```console
   
signal/sig_actionsignal/sig_actionsignal/sig_actionsignal/sig_actionsignal/sig_actionsignal/sig_actionsignal/sig_actionsignal/sig_...
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-27 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2914780509

   Going to post a link to the email thread here for record-keeping purposes, 
since KR seems to be more reachable there: 
https://lists.apache.org/thread/qlg38b9s1fzlyfscpldbfztcvc94fr2j


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-27 Thread via GitHub


acassis commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2912501535

   @linguini1 I'm copying KR message here (since he doesn't use github)
   
   ```
   I found some time to look into this and I believe I found the reason for
   "If you add avr_lowputc calls in the board initialization code, you'll
   see that the TX LED stays stuck on indefinitely."
   
   Provided the board initialization code that sentence is talking about is
   atmega_boardinitialize() in avr_boot.c, then avr_lowputc() likely does
   not work because of the configuration used. According to #16444, the
   configuration has:
   
   CONFIG_DEV_CONSOLE=y
   CONFIG_CONSOLE_SYSLOG=y
   
   These two are processed in src/atmega/atmega_config.h
   
   #ifndef CONFIG_DEV_CONSOLE
   #  undef  USE_SERIALDRIVER
   #  undef  USE_EARLYSERIALINIT
   #else
   #  if defined(CONFIG_CONSOLE_SYSLOG)
   #undef  USE_SERIALDRIVER
   #undef  USE_EARLYSERIALINIT
   #  elif defined(HAVE_USART_DEVICE)
   #define USE_SERIALDRIVER 1
   #define USE_EARLYSERIALINIT 1
   #  else
   #undef  USE_SERIALDRIVER
   #undef  USE_EARLYSERIALINIT
   #  endif
   #endif
   
   With the configuration above, the outer ifndef is not true and first if
   defined in else block is true, which results into:
   
   undef  USE_SERIALDRIVER
   undef  USE_EARLYSERIALINIT
   
   Since CONFIG_STANDARD_SERIAL is also set, the undef of USE_SERIALDRIVER
   is reverted by define USE_SERIALDRIVER 1 later. However,
   USE_EARLYSERIALINIT remains unset.
   
   This causes avr_earlyserialinit() to not be built nor called from
   avr_lowinit(). Serial port peripheral is therefore not initialized yet
   when atmega_boardinitialize() is called. I don't know what exactly
   happens when you attempt to transmit data with the port not enabled but
   my guess would be that "transmit data register empty" status flag is
   just never cleared and the program ends up in a loop waiting for that to
   happen.
   
   
   Other than that - I recently tested NSH on mega1284p-xplained (well, a
   breadboard with the chip stuck in it actually) and it worked for me. As
   far as I can see, all AtMega devices use the same code for managing
   serial ports so it should work out of the box.
   
   Someone somewhere in some forum on the net has or had a footer in his
   posts saying something along the lines of that non-functional serial
   port is 99% mismatching baud rates, might be worth a re-check.
   
   As for the PR itself (copying from e-mail mentioned at the beginning) -
   I would recommend trying to use KEEP(*(.vectors)) as seen in
   boards/avr/avrdx/breadxavr/scripts/breadxavr.ld - the default config
   should then not need the "# CONFIG_DEBUG_OPT_UNUSED_SECTIONS is not set"
   line.
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2911020129

   I can't seem to get a working version of `arduino-mega2560:nsh` or 
`arduino-mega2560:hello` as far back as `releases/11.0`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2910989594

   It appears that the `nodesize` ends up being equal to 0, while 
``MM_MIN_CHUNK`` is equal to 8.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2910959393

   I see this output:
   
   ```
   1a1a1a
   ```
   
   with these configuration settings:
   
   ```
   
   # CONFIG_DEBUG_OPT_UNUSED_SECTIONS is not set
   CONFIG_ARCH="avr"
   CONFIG_ARCH_AVR=y
   CONFIG_ARCH_BOARD="arduino-mega2560"
   CONFIG_ARCH_BOARD_ARDUINO_MEGA2560=y
   CONFIG_ARCH_CHIP="atmega"
   CONFIG_ARCH_CHIP_ATMEGA2560=y
   CONFIG_ARCH_CHIP_ATMEGA=y
   CONFIG_ARCH_STACKDUMP=y
   CONFIG_AVR_LINUXGCC_TOOLCHAIN=y
   CONFIG_AVR_USART0=y
   CONFIG_BOARD_LOOPSPERMSEC=800
   CONFIG_DEBUG_ASSERTIONS=y
   CONFIG_DEBUG_ASSERTIONS_FILENAME=y
   CONFIG_DEBUG_FEATURES=y
   CONFIG_DEBUG_FULLOPT=y
   CONFIG_DEBUG_SYMBOLS=y
   CONFIG_DEFAULT_SMALL=y
   CONFIG_DISABLE_MOUNTPOINT=y
   CONFIG_IDLETHREAD_STACKSIZE=128
   CONFIG_INIT_ENTRYPOINT="nsh_main"
   CONFIG_INIT_STACKSIZE=768
   CONFIG_INTELHEX_BINARY=y
   CONFIG_NDEBUG=y
   CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
   CONFIG_NUNGET_CHARS=0
   CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=768
   CONFIG_PTHREAD_STACK_DEFAULT=128
   CONFIG_PTHREAD_STACK_MIN=128
   CONFIG_RAM_SIZE=8192
   CONFIG_RAM_START=0x800100
   CONFIG_START_DAY=16
   CONFIG_START_MONTH=6
   CONFIG_START_YEAR=2011
   CONFIG_STDIO_BUFFER_SIZE=0
   CONFIG_SYSTEM_NSH=y
   CONFIG_TASK_NAME_SIZE=0
   CONFIG_USART0_BAUD=38400
   CONFIG_USART0_SERIAL_CONSOLE=y
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2910954170

   With the following modifications:
   
   ```c
   static inline_function void mm_addfreechunk(FAR struct mm_heap_s *heap,
   FAR struct mm_freenode_s *node)
   {
 FAR struct mm_freenode_s *next;
 FAR struct mm_freenode_s *prev;
 size_t nodesize = MM_SIZEOF_NODE(node);
 int ndx;
   
   if (!(nodesize >= MM_MIN_CHUNK)){
   up_putc('1');
   }
   
   if (!(MM_NODE_IS_FREE(node))){
   up_putc('2');
   }
   
   up_putc('a');
 DEBUGASSERT(nodesize >= MM_MIN_CHUNK);
   up_putc('b');
 DEBUGASSERT(MM_NODE_IS_FREE(node));
   up_putc('c');
   
 /* ... */
   ```
   
   I see this output (repeats forever as it spuriously reboots):
   
   ```console
   12a12a12a12a
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2910871301

   Using `up_putc` statements I have narrowed down the issue to a failing 
`DEBUASSERT(MM_NODE_IS_FREE(node))` in `mm/mm_heap/mm.h`'s definition of 
`mm_addfreechunk`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] ATMega2560 USART0 not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16444:
URL: https://github.com/apache/nuttx/issues/16444#issuecomment-2910830966

   I've found that the board seems to crash at the `kumm_initialize()` call in 
`nx_start`, and then restarts from the beginning forever. Continuing to debug 
what the issue is here.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]