Author Topic: ch32v307 Modbus + Web UI firmware  (Read 7530 times)

0 Members and 1 Guest are viewing this topic.

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #25 on: December 04, 2023, 02:07:38 pm »
Quote
Your output looks correct to me.
It's like yours but it does not print more stuff to the console,

Quote
But ....
Did you use the linker file from main-dir or the one from the vendor dir ?
The one from main dir prob. has to be adapted to 96K Ram.
I have used the linker file with is beside the mian.c file

Quote
Have you connected the "Blinky led" ?
See LED2 (top of main.c) for port/pin  - That one should/would blink to show mongoose is running.
Yes, and it's do not do anything, I think the board would crash after doing some stuff, since I do not know how to debug the code, I can not say what's the buggy function.

You have to modify the linkerfile to 96KB Ram
Either edit the one besides main , or copy the one from the vendor dir to the one in the main dir

 
The following users thanked this post: ali_asadzadeh

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: ch32v307 Modbus + Web UI firmware
« Reply #26 on: December 04, 2023, 03:15:17 pm »
Now, it starts to work, is there any chance that we can add FreeRTOS to it? also Is there a way to debug the code?
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #27 on: December 04, 2023, 05:07:26 pm »
Now, it starts to work, is there any chance that we can add FreeRTOS to it? also Is there a way to debug the code?

Why would you add FreeRTOS to mongoose ???
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: ch32v307 Modbus + Web UI firmware
« Reply #28 on: December 05, 2023, 08:08:33 am »
Quote
Why would you add FreeRTOS to mongoose ???
I need it to implement some tasks, also I have tested the demo app with ModbusDoctorV2 app, and it can not connect to the device using the 502 port, it only accepts port 80 But it would not respond back with modbus messages, I have tried the 192.168.1.3 and 192.168.1.100 IP's, the board would boot with 192.168.1.3 IP in my case.
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: ch32v307 Modbus + Web UI firmware
« Reply #29 on: December 05, 2023, 10:34:42 am »
I'm trying to port mongoose to mounriver studio, so at least we can debug it, Here is the progress till now, I have used FreeRTOS,

And this is the output uart

Quote
SystemClk:144000000
ChipID:30700518
FreeRTOS Kernel Version:V10.4.6
0      2 main.c:159:task2_task          Starting, CPU freq 144 MHz
2      2 main.c:162:task2_task          Heap size: 57224 bytes
5      2 main.c:167:task2_task          RAM/FLASH configuration: 96/224

when the program would hit this line
mg_tcpip_init(&mgr, &mif);

It would not go any further  and mounriver would not show the source file!!! But the task 1 is doing it's job, do you have any Idea what can cause this problem?


you can get the ported project at this link
https://www.file.io/GnAr/download/DYIfQcliAdGX
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #30 on: December 06, 2023, 12:48:34 pm »

It would not go any further  and mounriver would not show the source file!!! But the task 1 is doing it's job, do you have any Idea what can cause this problem?

Comment out "#define MG_ENABLE_LINES 1" in the mongoose_custom.h and rebuild. Then it should show the source.
Give mongoose task at least 8k of stack space.
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1906
  • Country: ca
Re: ch32v307 Modbus + Web UI firmware
« Reply #31 on: December 07, 2023, 08:43:22 am »
Thanks tellurium
Now it shows the sources, But it would stuck at this line
it's line 9309 in mongoose.c
Quote
while ((ETH->DMABMR & MG_BIT(0)) != 0) (void) 0;  // Wait until done
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #32 on: December 26, 2023, 07:58:25 pm »
Thanks tellurium
Now it shows the sources, But it would stuck at this line
it's line 9309 in mongoose.c

I have installed MRS, created a basic printf project, and moved mongoose code from the bare metal example - works for me.
Must be something with initialisation, I suspect ethernet MAC/PHY controller init is missing.

Could you share your MRS project please?
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #33 on: December 27, 2023, 10:56:16 pm »
We recently added a built-in TLS1.3 stack to Mongoose Library (server part for now).

I did an experimental build of the modbus firmware with TLS enabled.
Didn't manage to get it to work on 32k RAM configuration - too tight!
Note that the browser spawns multiple (~5) connections to speed up HTML GUI rendering, meaning that the box gets hit by ~5 simultaneous TLS connections, which are both RAM and CPU hungry.

But lo and behold, with 64k RAM configuration, it works! Flaky sometimes, but works.
To build with TLS, change vendor/link.ld to 256/64 configuration, then "make CFLAGS_EXTRA="-DMG_TLS=MG_TLS_BUILTIN".
Screenshot attached.

TLS-enabled firmware build is attached to the 1st post.
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14481
  • Country: fr
Re: ch32v307 Modbus + Web UI firmware
« Reply #34 on: December 27, 2023, 11:12:39 pm »
How much Flash do you use? You know you can get up to 128KB RAM with the proper config - it'll limit the available code memory to 192KB though. Might still be workable!
 

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #35 on: December 27, 2023, 11:23:18 pm »
How much Flash do you use? You know you can get up to 128KB RAM with the proper config - it'll limit the available code memory to 192KB though. Might still be workable!

This current TLS-enabled build is 110344 bytes, which is below half of the available flash size (256 / 2 = 128k). Plenty of room is there yet!
Meaning, even firmware update is possible.

So, on this CH32V307, it is possible to create a TLS-enabled Web UI dashboard with firmware update functionality.
The flash content would be wide open of course, but still.
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14481
  • Country: fr
Re: ch32v307 Modbus + Web UI firmware
« Reply #36 on: December 27, 2023, 11:36:07 pm »
The memory layout of this chip is documented (sorta) but not really advertised. Not sure why. So people tend not to know, or assume that may not work, and so on.

To sum up again, the CH32V307 has:
- A total of 320KB RAM
- A total of 480KB Flash

Due to how the memory is mapped for code execution (which uses some amount of RAM to cache access, which I suspect is just a full copy of your code Flash content at boot), you only have access to a maximum of 288KB of code memory (in this case, with a data memory of 32KB), or a maximum of 192KB code memory (with a data memory of 128KB), and a couple combinations in between.

The calculation is simple, available code memory = 320KB - available data memory. That makes it obvious all code is loaded from Flash to RAM at boot. No code ever executes directly from Flash, which is why the chip has a guaranteed zero-wait-state access to code memory at all system clock frequencies.

Besides, anything in Flash above the max code memory size in a given configuration is usable for anything else up to the 480KB limit. So in a 192KB "Flash"/128KB "RAM" configuration, you still have 480KB - 192KB (288KB !) of Flash usable to store anything, a second copy of the whole code, user data, etc.

That gives a lot more possibilities that many people appear to think when exposed to the CH32V307.
Why WCH doesn't advertise this more is unknown to me. It's fully (albeit not overly detailed) documented in the DS and RM documents.
But note that if you base your impression of the chip on just intrroduction parts of the docs and the provided SDK and examples, you'll miss out on a lot of stuff. The examples they provide are very limited and only show a fraction of the possibilities, and that's true for almost all aspects of the chip, from memory to USB.
« Last Edit: December 27, 2023, 11:38:16 pm by SiliconWizard »
 
The following users thanked this post: tellurium

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #37 on: December 28, 2023, 12:59:05 am »
Would this be a correct summary?


Possible RAM/Flash configurations for CH32V307:

32k data / 288k code:   |-32-|----------288------|
64k data / 256k code:   |-64---|--------256------|
96k data / 224k code:   |-96-----|------224------|
128k data / 192k code:  |-128-------|---192------|

                        |<--------- 320k ------->|

This configuration is stored in the flash option bytes.
Here is a function that sets the required configuration:
https://github.com/cesanta/mongoose/blob/3965aecfd473cbd70027b636492bb19b615eadd4/examples/wch/ch32v307-make-baremetal-builtin/hal.h#L121-L136

Flash is mapped at address 0x8000000 and 0x0, and is of size 480k.
There is available flash "scratch space" of size "480k - codesize" that
can be used for persistent storage. The initial "code" portion gets copied into RAM for execution.

   0x0
   |------ code -----|------------- storage space -------|

   |<---------------------- 480k ----------------------->|
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14481
  • Country: fr
Re: ch32v307 Modbus + Web UI firmware
« Reply #38 on: December 28, 2023, 02:50:47 am »
Yes, the only thing to add probably is that as far as Flash address mapping goes, while it is indeed remapped at address 0 for *reading*, I think you still need to use addresses starting at 0x8000000 for *writing* to Flash.
 
The following users thanked this post: tellurium

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #39 on: January 21, 2024, 05:34:12 am »
I have this board & programmer
https://www.aliexpress.com/item/1005005021450761.html
CH32V307 EVT (by SCDZ, close to official W.CH board)

I don't have that board, ordered and expecting it to arrive in a couple of weeks.


@tellurium
Did you ever get the board above ?

/Bingo
 

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #40 on: January 21, 2024, 11:51:21 am »
@tellurium
Did you ever get the board above ?
/Bingo

Yes I did! The latest change to the code I've done with that board.
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #41 on: January 21, 2024, 02:48:12 pm »
@tellurium
Did you ever get the board above ?
/Bingo

Yes I did! The latest change to the code I've done with that board.

I just tried the latest code , and i still have that ethernet issue ....
After programming or a POR it just "hangs here"

Code: [Select]
2b19   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
2f01   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
32e9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
36d1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
3ab9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
3ea1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
4289   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
4671   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
4a59   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
4e41   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
5229   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051
5611   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/8051


If i press reset ... It will get an ip

Or if i test for ethernet link , and do a NVIC Reset. It will also get an ip.

Code: [Select]
static void timer_fn(void *arg) {
  gpio_toggle(LED_PIN);                                  // Blink LED_PIN
  struct mg_tcpip_if *ifp = arg;                         // And show
  const char *names[] = {"down", "up", "req", "ready"};  // network stats
  MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u RAM: %lu/%lu",
           names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent,
           ifp->ndrop, ifp->nerr, hal_ram_used(), hal_ram_free()));

#if 1
  if(0 == ifp->state)
  {
    NVIC_SystemReset();
  }
#endif

}

Wonder if my board is strange ??
I'm still waiting for a some of "your old" boards from Ali ....


Edit: I'm programming & powering via a - WCHLink USB Dongle (the cheap one wo buttons) , that came w. the set
Using minichlink with my patches for Ram/Rom assignment
https://www.eevblog.com/forum/microcontrollers/ch32v307-risc-v-minicore-with-ethernet/msg5197074/#msg5197074

Attached the modified makefile  (just 3 lines)



Edit2:
I tried to add 22uF and even 100uF to the 5v rail  ...  Same issue

Edit3:
The reason i'm not doing wireshark traces, is that the "link is down" ....

/Bingo

« Last Edit: January 21, 2024, 03:21:39 pm by bingo600 »
 

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #42 on: January 21, 2024, 07:56:47 pm »
I consistently get everything working after flashing.
Here is what I am doing:

Terminal1 - building & flashing
Code: [Select]
$ git clone https://github.com/cesanta/mongoose
$ cd mongoose/examples/wch/ch32v307-make-baremetal-builtin
$ make CFLAGS_EXTRA='-Wl,--defsym -Wl,RAM_64K=1' clean all
$ wlink flash firmware.elf

Terminal2 - reading serial logs
Code: [Select]
$ cu -l /dev/cu.usb* -s 115200                                                                                           
Connected.                                                                                                                 
0      2 main.c:46:main                 Starting, CPU freq 144 MHz                                                         
5      2 main.c:51:main                 RAM/FLASH configuration: 64/256                                                   
c      2 main.c:55:main                 Heap size: 48032 bytes. RAM: used 1032, free 50823                                 
14     3 stm32f.c:152:mg_tcpip_driver_s PHY ID: 0x00 0x00                                                                 
19     2 main.c:70:main                 MAC: 02:50:5c:7e:39:e3. Waiting for IP...                                         
401    3 stm32f.c:201:mg_tcpip_driver_s Link is 10M half-duplex                                                           
406    1 net_builtin.c:202:onstatechang Link up                                                                           
40a    3 net_builtin.c:302:tx_dhcp_disc DHCP discover sent. Our MAC: 02:50:5c:7e:39:e3                                     
412    3 net_builtin.c:281:tx_dhcp_requ DHCP req sent                                                                     
417    2 main.c:26:timer_fn             Ethernet: req, IP: 0.0.0.0, rx:3, tx:2, dr:0, er:0 RAM: 10860/40787               
420    2 net_builtin.c:408:rx_dhcp_clie Lease: 86400 sec (86401)                                                           
426    2 net_builtin.c:197:onstatechang READY, IP: 192.168.2.86                                                           
42c    2 net_builtin.c:198:onstatechang        GW: 192.168.2.1                                                             
431    2 net_builtin.c:199:onstatechang       MAC: 02:50:5c:7e:39:e3                                                       

That I am getting consistently. I cannot reproduce that behavior you're talking about.
Note that the CFLAGS_EXTRA='-Wl,--defsym -Wl,RAM_64K=1' build flag is used to build for 256/64 flash/ram configuration, which is the default for that board.

I got my board from Elektor, unpacked and connected to my USB hub with Ethernet port, no modifications/alterations made.
« Last Edit: January 21, 2024, 08:03:38 pm by tellurium »
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #43 on: January 22, 2024, 05:18:17 am »
I consistently get everything working after flashing.
Here is what I am doing:

Terminal1 - building & flashing
Code: [Select]
$ git clone https://github.com/cesanta/mongoose
$ cd mongoose/examples/wch/ch32v307-make-baremetal-builtin
$ make CFLAGS_EXTRA='-Wl,--defsym -Wl,RAM_64K=1' clean all
$ wlink flash firmware.elf
                                       


That I am getting consistently. I cannot reproduce that behavior you're talking about.
Note that the CFLAGS_EXTRA='-Wl,--defsym -Wl,RAM_64K=1' build flag is used to build for 256/64 flash/ram configuration, which is the default for that board.

I got my board from Elektor, unpacked and connected to my USB hub with Ethernet port, no modifications/alterations made.

I didn't use any extra flags , but gave it 96K Ram on flashing.
I'll try your "extra's"

/Bingo 
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #44 on: January 22, 2024, 03:46:05 pm »
I tried with the EXTRA def's , and no luck ....

But then i tried with another switch

My original switch is a HP-1820 8-port , and i switched to a Dlink DGS-1100-08 V2
Now it's getting link , but it has to do a lot of "link down" first

Code: [Select]
0      2 main.c:46:main                 Starting, CPU freq 144 MHz
5      2 main.c:51:main                 RAM/FLASH configuration: 64/256
c      2 main.c:55:main                 Heap size: 48032 bytes. RAM: used 1032, free 50823
14     3 stm32f.c:152:mg_tcpip_driver_s PHY ID: 0x00 0x00
19     2 main.c:70:main                 MAC: 02:38:32:38:38:e7. Waiting for IP...
409    2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
7f1    2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
bd9    2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
fc1    2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
13a9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
1791   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
1b79   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
1f61   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
2349   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
2731   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
2b19   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
2f01   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
32e9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
36d1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
3ab9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
3ea1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
4289   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
4671   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
4a59   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
4e41   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
5229   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
5611   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
59f9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
5de1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
61c9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
65b1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
6999   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
6d81   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
7169   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
7551   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
7939   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
7d21   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
8109   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
84f1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
88d9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
8cc1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
90a9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
9491   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
9879   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
9c61   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
a049   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
a431   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
a819   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
ac01   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
afe9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
b3d1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
b7b9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
bba1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
bf89   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
c371   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
c759   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
cb41   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
cf29   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
d311   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
d6f9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
dae1   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
dec9   2 main.c:26:timer_fn             Ethernet: down, IP: 0.0.0.0, rx:0, tx:0, dr:0, er:0 RAM: 10828/40819
e2a9   3 stm32f.c:201:mg_tcpip_driver_s Link is 10M half-duplex
e2ae   1 net_builtin.c:202:onstatechang Link up
e2b2   3 net_builtin.c:302:tx_dhcp_disc DHCP discover sent. Our MAC: 02:38:32:38:38:e7
e2ba   2 main.c:26:timer_fn             Ethernet: up, IP: 0.0.0.0, rx:1, tx:1, dr:0, er:0 RAM: 10860/40787
e691   3 net_builtin.c:302:tx_dhcp_disc DHCP discover sent. Our MAC: 02:38:32:38:38:e7
e699   2 main.c:26:timer_fn             Ethernet: up, IP: 0.0.0.0, rx:1, tx:2, dr:0, er:0 RAM: 10860/40787
e6a2   3 net_builtin.c:281:tx_dhcp_requ DHCP req sent
e6a7   2 net_builtin.c:408:rx_dhcp_clie Lease: 6793 sec (6852)
e6ac   2 net_builtin.c:197:onstatechang READY, IP: 10.1.1.210
e6b2   2 net_builtin.c:198:onstatechang        GW: 10.1.1.1
e6b8   2 net_builtin.c:199:onstatechang       MAC: 02:38:32:38:38:e7
e6be   2 main.c:75:main                 Initialising application...
e6c4   3 net.c:202:mg_listen            1 0 http://0.0.0.0:8000
e6c9   3 net.c:202:mg_listen            2 0 http://0.0.0.0/
e6cf   3 net.c:202:mg_listen            3 0 https://0.0.0.0/
e6d4   2 main.c:79:main                 Starting event loop
e6d9   3 net.c:177:mg_connect           4 -1 udp://time.google.com:123
e6e0   3 net.c:177:mg_connect           5 -1 udp://8.8.8.8:53
e6e5   3 net_builtin.c:997:mg_connect_r 5 10.1.1.210:32768 -> 8.8.8.8:53
ea81   2 main.c:26:timer_fn             Ethernet: ready, IP: 10.1.1.210, rx:4, tx:5, dr:0, er:0 RAM: 12060/39587
ee69   2 main.c:26:timer_fn             Ethernet: ready, IP: 10.1.1.210, rx:5, tx:5, dr:0, er:0 RAM: 12060/39587
f251   2 main.c:26:timer_fn             Ethernet: ready, IP: 10.1.1.210, rx:5, tx:5, dr:0, er:0 RAM: 12060/39587
f299   3 net.c:151:mg_close_conn        4 -1 closed
f639   2 main.c:26:timer_fn             Ethernet: ready, IP: 10.1.1.210, rx:5, tx:5, dr:0, er:0 RAM: 12060/39587

Wonder if i'm fighting spanning tree (i have rstp) enabled on the HP ... Well no RSTP on the D-Link
It seems like it gets a link quicker from POR , than programming ....

Well ... I'll wait for my other boards (en route from Ali...)

@tellurium
Thank you for your support ....

And still strange that a NVIC Reset if no link , brings the link up immediately on next boot.

/Bingo
« Last Edit: January 22, 2024, 04:01:10 pm by bingo600 »
 

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #45 on: January 22, 2024, 03:54:37 pm »
It looks like it has no problem getting an IP when it senses the link

"Ethernet: down" - this means that the driver does not think there is a link, so it does not even try to send DHCP requests.

And, by the way, you've built with 64k RAM support, I can see here: " RAM: 10828/40819"
40k free RAM. By default, without CFLAGS_EXTRA, it is less than that.
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #46 on: January 22, 2024, 04:05:52 pm »
It looks like it has no problem getting an IP when it senses the link

"Ethernet: down" - this means that the driver does not think there is a link, so it does not even try to send DHCP requests.
Yepp , once it gets the ether-link it's quite fast to get the ip via dhcp.
But it's struggling a bit to obtain the link, i can see the switchport led is out ...

And, by the way, you've built with 64k RAM support, I can see here: " RAM: 10828/40819"
40k free RAM. By default, without CFLAGS_EXTRA, it is less than that.

Yep - I did your extras flag.

Here's my latest Makefile.
I added a linker map , and a linker flash/ram printout


The switchport strangeness is weird.
I have no issue getting a link/ip - If i use the same cable/port on the HP , on a Raspi3 or OrangePi-One , but they prob linkup on 100Mb

« Last Edit: January 22, 2024, 04:09:52 pm by bingo600 »
 
The following users thanked this post: tellurium

Offline telluriumTopic starter

  • Regular Contributor
  • *
  • Posts: 229
  • Country: ua
Re: ch32v307 Modbus + Web UI firmware
« Reply #47 on: January 22, 2024, 04:38:08 pm »
Thank you!
Did you try to build a Mounriver example? I am curious, would it be able to sense the link, or have the same issue
Open source embedded network library https://mongoose.ws
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #48 on: January 22, 2024, 05:54:40 pm »
I don't have mounriver installed ...
Right now i just use : xpack-riscv-none-elf-gcc-13.2.0-2

I'm not always that keen on installing "strange IDE's"
But i have just downloaded it ...

I'm on linux (mint)
Seems like the DL is just the toolchain + OOCD

Well i do have Eclipse installed already ....

Maybe i'll consider



Any pointers to a "working" MounRiver example ?


« Last Edit: January 22, 2024, 06:16:21 pm by bingo600 »
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: ch32v307 Modbus + Web UI firmware
« Reply #49 on: January 22, 2024, 07:15:29 pm »
Well I just did try ddrown's iperf server

https://github.com/ddrown/ch32v307-lwip-example

Here i have an issue too..

Code: [Select]
Error:Wait phy linking timeout!
Please cheak MID.
Program has been blocked!

And after pressing "Board reset" , it works.

Code: [Select]
Enter main loop.
PLL3 is ready.
PHY_SR value:0004.
Full Duplex.
CH307_INIT_PHY ok
enable rng ok
This routine will use DHCP to dynamically assign IP addresses.
本例程将使用DHCP动态分配IP地址,如果不需要则在lwipopts.h中将LWIP_DHCP定义为0

lwip dhcp start success...

IP 10.1.1.211


Neat iperf test  :-+
Code: [Select]
~/1-RiscV/gcc$ iperf -i 1 -c ch32v307
------------------------------------------------------------
Client connecting to ch32v307, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 10.1.1.182 port 54988 connected with 10.1.1.211 port 5001
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-1.0000 sec  1.13 MBytes  9.44 Mbits/sec
[  1] 1.0000-2.0000 sec  1.12 MBytes  9.44 Mbits/sec
[  1] 2.0000-3.0000 sec  1.12 MBytes  9.44 Mbits/sec
[  1] 3.0000-4.0000 sec  1.12 MBytes  9.44 Mbits/sec
[  1] 4.0000-5.0000 sec   896 KBytes  7.34 Mbits/sec
[  1] 5.0000-6.0000 sec  1.12 MBytes  9.44 Mbits/sec
[  1] 6.0000-7.0000 sec  1.12 MBytes  9.44 Mbits/sec
[  1] 7.0000-8.0000 sec  1.12 MBytes  9.44 Mbits/sec
[  1] 8.0000-9.0000 sec  1.00 MBytes  8.39 Mbits/sec
[  1] 9.0000-10.0000 sec  1.00 MBytes  8.39 Mbits/sec
[  1] 0.0000-10.1062 sec  10.9 MBytes  9.03 Mbits/sec
:~/1-RiscV/gcc$


So it seems like i have a local issue somewhere

I think i'll get my other boards from ali soon , seems like they have cleared customs ...
Let's see if they have same issue.

/Bingo
« Last Edit: January 22, 2024, 07:28:24 pm by bingo600 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf