mwalle / shinelanx-modbus

An alternative firmware for the Growatt ShineLAN-X stick
4 stars 1 forks source link

Error when compiling Nuttx #3

Closed fortschritt311 closed 3 months ago

fortschritt311 commented 3 months ago

Hi.

When i want to compile Nuttx i get the follwing error on Ubuntu 24.04 (especially the last four lines):

xxx@VGN-FW54M:~/shine/nuttx# make -j$(nproc)
Create version.h
LN: platform/board to /xxx/shine/apps/platform/dummy
Register: mbusd
Register: shinelanx_modbus_gw

CC:  signal/sig_ismember.c chip/stm32_gpio.c:41:11: note: '#pragma message: CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py'
   41 | #  pragma message "CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py"
      |           ^~~~~~~

CC:  stdio/lib_vsprintf.c chip/stm32_usbdev.c: In function 'stm32_wrrequest':
chip/stm32_usbdev.c:1348:2: warning: #warning "REVISIT: If the EP supports double buffering, then we can do better" [-Wcpp]
 1348 | #warning "REVISIT: If the EP supports double buffering, then we can do better"
      |  ^~~~~~~

chip/stm32_usbdev.c: In function 'stm32_epconfigure':

chip/stm32_usbdev.c:2887:2: warning: #warning "REVISIT: Need to review isochronous EP setup" [-Wcpp]
 2887 | #warning "REVISIT: Need to review isochronous EP setup"
      |  ^~~~~~~

chip/stm32_usbdev.c:2905:2: warning: #warning "REVISIT: Should configure BULK EPs using double buffer feature" [-Wcpp]
 2905 | #warning "REVISIT: Should configure BULK EPs using double buffer feature"
      |  ^~~~~~~

chip/stm32_usbdev.c: In function 'stm32_allocep':

chip/stm32_usbdev.c:3380:2: warning: #warning "REVISIT: Should configure BULK EPs using double buffer feature" [-Wcpp]
 3380 | #warning "REVISIT: Should configure BULK EPs using double buffer feature"
      |  ^~~~~~~

CC:  stdio/lib_libvscanf.c In file included from chip/stm32_dumpgpio.c:34:
chip/stm32_dumpgpio.c: In function 'stm32_dumpgpio':
chip/stm32_dumpgpio.c:110:9: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  110 |   _info("GPIO%c pinset: %08x base: %08x -- %s\n",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111 |        g_portchar[port], pinset, base, msg);
      |                          ~~~~~~
      |                          |
      |                          uint32_t {aka long unsigned int}
chip/stm32_dumpgpio.c:110:28: note: format string is defined here
  110 |   _info("GPIO%c pinset: %08x base: %08x -- %s\n",
      |                         ~~~^
      |                            |
      |                            unsigned int
      |                         %08lx
chip/stm32_dumpgpio.c:110:9: warning: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  110 |   _info("GPIO%c pinset: %08x base: %08x -- %s\n",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111 |        g_portchar[port], pinset, base, msg);
      |                                  ~~~~
      |                                  |
      |                                  uint32_t {aka long unsigned int}
chip/stm32_dumpgpio.c:110:39: note: format string is defined here
  110 |   _info("GPIO%c pinset: %08x base: %08x -- %s\n",
      |                                    ~~~^
      |                                       |
      |                                       unsigned int
      |                                    %08lx
chip/stm32_dumpgpio.c:115:13: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:115:23: note: format string is defined here
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |                    ~~~^
      |                       |
      |                       unsigned int
      |                    %08lx
chip/stm32_dumpgpio.c:115:13: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:115:28: note: format string is defined here
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |                         ~~~^
      |                            |
      |                            unsigned int
      |                         %08lx
chip/stm32_dumpgpio.c:115:13: warning: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:115:38: note: format string is defined here
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |                                   ~~~^
      |                                      |
      |                                      unsigned int
      |                                   %04lx
chip/stm32_dumpgpio.c:115:13: warning: format '%x' expects argument of type 'unsigned int', but argument 6 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:115:48: note: format string is defined here
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |                                             ~~~^
      |                                                |
      |                                                unsigned int
      |                                             %04lx
chip/stm32_dumpgpio.c:115:13: warning: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:115:59: note: format string is defined here
  115 |       _info("  CR: %08x %08x IDR: %04x ODR: %04x LCKR: %04x\n",
      |                                                        ~~~^
      |                                                           |
      |                                                           unsigned int
      |                                                        %04lx
chip/stm32_dumpgpio.c:121:13: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:121:25: note: format string is defined here
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |                      ~~~^
      |                         |
      |                         unsigned int
      |                      %02lx
chip/stm32_dumpgpio.c:121:13: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:121:36: note: format string is defined here
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |                                 ~~~^
      |                                    |
      |                                    unsigned int
      |                                 %08lx
chip/stm32_dumpgpio.c:121:13: warning: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:121:45: note: format string is defined here
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |                                          ~~~^
      |                                             |
      |                                             unsigned int
      |                                          %04lx
chip/stm32_dumpgpio.c:121:13: warning: format '%x' expects argument of type 'unsigned int', but argument 6 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:121:50: note: format string is defined here
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |                                               ~~~^
      |                                                  |
      |                                                  unsigned int
      |                                               %04lx
chip/stm32_dumpgpio.c:121:13: warning: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:121:55: note: format string is defined here
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |                                                    ~~~^
      |                                                       |
      |                                                       unsigned int
      |                                                    %04lx
chip/stm32_dumpgpio.c:121:13: warning: format '%x' expects argument of type 'unsigned int', but argument 8 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:121:60: note: format string is defined here
  121 |       _info("  EVCR: %02x MAPR: %08x CR: %04x %04x %04x %04x\n",
      |                                                         ~~~^
      |                                                            |
      |                                                            unsigned int
      |                                                         %04lx
chip/stm32_dumpgpio.c:130:13: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  130 |       _info("  GPIO%c not enabled: APB2ENR: %08x\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chip/stm32_dumpgpio.c:130:48: note: format string is defined here
  130 |       _info("  GPIO%c not enabled: APB2ENR: %08x\n",
      |                                             ~~~^
      |                                                |
      |                                                unsigned int
      |                                             %08lx
CC:  stdio/lib_vfprintf.c conn.c:55:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
   55 | int tty_reopen()
      |     ^~~~~~~~~~
conn.c:74:6: warning: function declaration isn't a prototype [-Wstrict-prototypes]
   74 | void tty_reinit()
      |      ^~~~~~~~~~
conn.c: In function 'conn_tty_start':
conn.c:207:27: warning: declaration of 'tty' shadows a global declaration [-Wshadow]
  207 | conn_tty_start(ttydata_t *tty, conn_t *conn)
      |                ~~~~~~~~~~~^~~
conn.c:42:18: note: shadowed declaration is here
   42 | extern ttydata_t tty;
      |                  ^~~
conn.c: In function 'conn_write':
conn.c:249:8: warning: unused variable 'delay' [-Wunused-variable]
  249 |   long delay;
      |        ^~~~~
conn.c:248:22: warning: unused variable 'tts' [-Wunused-variable]
  248 |   struct timeval ts, tts;
      |                      ^~~
conn.c:248:18: warning: unused variable 'ts' [-Wunused-variable]
  248 |   struct timeval ts, tts;
      |                  ^~
conn.c: In function 'conn_loop':
conn.c:304:11: warning: declaration of 'max_sd' shadows a global declaration [-Wshadow]
  304 |   int rc, max_sd, len, min_timeout;
      |           ^~~~~~
conn.c:46:5: note: shadowed declaration is here
   46 | int max_sd; /* major descriptor in the select() sets */
      |     ^~~~~~
conn.c:650:29: warning: declaration of 'i' shadows a previous local [-Wshadow]
  650 |               unsigned char i;
      |                             ^
conn.c:305:16: note: shadowed declaration is here
  305 |   unsigned int i;
      |                ^
conn.c:856:30: warning: declaration of 'len' shadows a previous local [-Wshadow]
  856 |                 unsigned int len;
      |                              ^~~
conn.c:304:19: note: shadowed declaration is here
  304 |   int rc, max_sd, len, min_timeout;
      |                   ^~~
conn.c:305:16: warning: unused variable 'i' [-Wunused-variable]
  305 |   unsigned int i;
      |                ^
CC:  stdio/lib_ferror.c conn.c:867:30: warning: 'len' may be used uninitialized [-Wmaybe-uninitialized]
  867 |                 if (len == 0 || len > BUFSIZE - 2)
      |                     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
conn.c:856:30: note: 'len' was declared here
  856 |                 unsigned int len;
      |                              ^~~
LD: nuttx

arm-none-eabi-ld: /xxx/shine/nuttx/staging/libnet.a(udp_ioctl.o): in function 'udp_path':
/xxx/shine/nuttx/net/udp/udp_ioctl.c:72:(.text.udp_ioctl+0x8a): undefined reference to 'udp_wrbuffer_inqueue_size'
make[1]: *** [Makefile:197: nuttx] Fehler 1
make: *** [tools/Unix.mk:537: nuttx] Fehler 2

Thanks & Greetings Maik

mwalle commented 3 months ago

Hi Maik,

that error message does ring a bell. Did you check out the "nuttx-12.3.0" tag and not compiling with the latest HEAD?

-michael

fortschritt311 commented 3 months ago

Hi Michael,

yes i used the tag "-b nuttx-12.3.0", as specified in the instructions.

Maik

mwalle commented 3 months ago

Strange. Unfortunately, I cannot test it right now because I'm busy with other stuff. Did you clone this repo? Then, the gh actions (incl the image build) should also be cloned. Can you check it that worked?

FWIW, I've used debian. But the GH action use an ubuntu image.

Doh. I just see the GH actions use the nuttx-12.2.1 tag. So maybe I was (and the README is) wrong. Could you please check that tag?

fortschritt311 commented 3 months ago

With the 12.2.1 tag the same warnings appear but at the end the image is created:

LD: nuttx
CP: nuttx.hex
CP: nuttx.bin

I'll try it out and give you some feedback.

Thanks Maik.

mwalle commented 3 months ago

Yeah, the warnings are "normal" probably due to a new compiler which will throw more warnings. Or maybe nuttx isn't warning free anyway. The same goes for mbusd.

btw if you only want to have the binary there is also: https://github.com/mwalle/shinelanx-modbus/releases/tag/r0

fortschritt311 commented 3 months ago

After i change the IP configuration to use static IP i downloaded the bin to the stick. This works, and i plugged the stick in the inverter. Now i can ping my static ip, but there is no modbus port available (502...)

nmap -p 502 192.168.xxx.xxx

Nmap scan report for 192.168.xxx.xxx
Host is up (0.0030s latency).

PORT    STATE  SERVICE
502/tcp closed mbap

I want to use the iobroker modbus adapter, but I get a socket error, because i get no connection.

mwalle commented 3 months ago

Looks like the mbusd isn't started (or the network isn't available when it starts). You don't have access to the serial console by chance, do you? You'll need to solder two Testpoints to a TTL level UART converter. Unfortunately, for now there is no easy way to get debugging over network. You could also play with this sleep here: https://github.com/mwalle/shinelanx-modbus/blob/main/apps/shinelanx-modbus-gw/main.c#L155

btw. for there is also pymodbus which you can use for modbus tcp testing, if you don't like the full iobroker stack for testing. but you're right, the port should be available first ;)

fortschritt311 commented 3 months ago

Hi. I have set sleep to 10s. Now it works. Mbus is running, the port is open.

Nmap scan report for 192.168.xx.xxx
Host is up (0.0030s latency).

PORT    STATE SERVICE
502/tcp open  mbap
MAC Address: xx:xx:xx:xx:xx:xx (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds

Now i play a little bit with the register in iobroker. Thanks for your support. Maik.

fortschritt311 commented 3 months ago

Ok, it works as desired. I get all the information from the inverter :-)

Best regards Maik