Any Support for booting from Spi Flash?

Follow the links given above.

Theres talk of the tool but no actual links to either cviDownloadTool or Usb Tool. Not even in the sophgo docs

I don’t really understand whether it is I got some different internets or something else is happening. :person_shrugging:

For some reason, I see the links and can download the tool and some driver installer by this link right away.

Keep in mind that the most basic Duo board is based on CV100B SoC, so whenever it is required that you specify the SoC model, you will have to edit the value.

I thought it was only for the Milk V duo S since it has emmc and I have Milkv duo 64.

Anyway seems this mcu is a headache. It doesnt even stay in download mode for the tool to work. Keeps connecting then disconnecting. I even removed the spi chip to check if its causing that but…still the same

In the chinese forum i saw this

u-boot code modification

As mentioned above, pulling up the USB_VBUS_DET pin can enter the USB burning mode. However, the SDK of milk-v duo defines the USB_VBUS_DET pin as ADC5 in u-boot, so this part of the code needs to be modified.

Modify build/boards/cv180x/cv1800b_milkv_duo_sd/u-boot/cvi_board_init.c the file and comment the following statement.

	// PINMUX_CONFIG(USB_VBUS_DET, XGPIOB_6);   // ADC2

If you are using spi-norflash or spi-nandflash, you can modify the cvi_board_init.c file in the corresponding directory.

Recompile after the modification is completed.

Added milkv-duo64-spinor-arduino-ion-usbboot.7z to the folder on MediaFire.

They do not share the same pins. Which pins are you using?

The chip should be fine. I have used a few W25Q256JVEQ chips.

Since you’ve got a working fip.bin (u-boot) for SPI NOR, and this sees only 0xFF (high values), the next step is to fix the wiring so sf probe succeeds.

U-Boot 2021.10 (Jul 31 2024 - 16:44:15 +0300)cvitek_cv180x

DRAM: 63.3 MiB
gd->relocaddr=0x823f3000. offset=0x21f3000
MMC: cv-sd@4310000: 0
Loading Environment from SPIFlash… spinor id = FF FF FF
jedec_spi_nor spi_flash@0:0: unrecognized JEDEC id bytes: ff, ff, ff
*** Warning - spi_flash_probe_bus_cs() failed, using default environment

In: serial
Out: serial
Err: serial
Net:
Warning: ethernet@4070000 (eth0) using random MAC address - 16:a8:f2:c9:36:30
eth0: ethernet@4070000
Hit any key to stop autoboot: 1  0

Resetting to default environment

Start USB downloading…

start usb task!
NOTICE: cvi_usb_hw_init
INFO: waiting for connection …
INFO: detect vbus …
INFO: bulkBufAlloc: 0000000081bd7b40
INFO: cmdBufAlloc: 0000000081bd7d80
INFO: ep0BuffAlloc: 0000000081be4100
INFO: setup_buf: 0000000081bd7fc0
INFO: handler: 0000000081bd8040
INFO: cb0_buf: 0000000081bd8450
INFO: cb1_buf: 0000000081bd84e0
INFO: cb2_buf: 0000000081bd8570
INFO: rsp_buf: 0000000081be4150
INFO: acm_buf: 0000000081bd8600
NOTICE: Overwrite fip_src to FIP_SRC_USB
NOTICE: fip_src 6
NOTICE: bind()
NOTICE: Patch VID 3346
NOTICE: Patch VID 3346
NOTICE: USB enumeration done
NOTICE: connection speed: 3
NOTICE: CVI_USB_REBOOT

Some minor success. It starts but freaks out and reboots

using terminal i use this command as stated in the docs. the files are in a folder named rom in the tools directory

.\usb_dl.exe -s linux -c cv180x -i .\rom\

it gives this error

[INFO] Waiting for USB device connection: |
[INFO] found usb device vid=0x3346 pid=0x1000
[INFO] fip_tx_offset: 0, fip_tx_size: 4096
[ERR] unable to open .\rom\fip.bin
[INFO] set MGN1 flag
[INFO] break

I tried even giving the full path still gives that error

Make sure to place fip.bin into rom subfolder.
Rinse and repeat, documenting every step up to success.

it is in the same folder. I also put it both in root of the usb tool and in the folder

I am using Milk V Duo 64MB. They do infact share the same pins. They are physically connected together. if you have a multimeter you can check them yourself. Also Memory cards have two interfaces for data/cmd one is Spi and the other SDA(much faster) . So MCU uses the Chip Select line to select which Chip it wants to communicate with. BUT On the milk V CS# line is also connected to SDCARD slot along with SCLK, DATA In, DATA Out, WP, Hold. So…Yeh

To prove it further the USB Tool also specifies that you must remove the sdcard when flashing emmc/spi flash

1 Like

But it somehow is unable to open it. :person_shrugging:

Well, probably it is useless for now, I can’t test it myself.

Nevertheless, the team behind the official Duo-Buildroot-SDK v1 took care and made these build options available to us. So in my opinion, our primary interest is how do we ever flash these files onto the flash chip?

One can deduce it from the SoC datasheet in Chinese.
If anyone knows where in the Duo-Buildroot-SDK we can find the flasher, please let us know.

Hi @KeiKai the topic is SPI flash and you mentioned using W25Q256 so I assumed you wanted to use that. Those pads under the card are for SD flash. You don’t need a special image to use that.

1 Like

I’m trying this tool myself, out of curiosity; @KeiKai where did you get the drivers for USB CDC and USB Serial devices?

Hi @hannahKobain the flasher tool is built from SDK into U-Boot and called cvi_update:

U-Boot 2021.10 (Jul 08 2024 - 20:48:52 +0100)cvitek_cv180x

DRAM:  63.3 MiB
gd->relocaddr=0x823f3000. offset=0x21f3000
MMC:   cv-sd@4310000: 0
Loading Environment from SPIFlash... spinor id = C8 40 17
SF: Detected GD25Q64E with page size 256 Bytes, erase size 4 KiB, total 8 MiB
OK
In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@4070000
Hit any key to stop autoboot:  0 
cv180x_c906# help cvi_update
cvi_update - cvi_update [eth, sd, usb]- check boot status and update if necessary

Source code is in u-boot-2021.10/cmd/cvi_update.c. In there, the process of reading into RAM and writing to flash is shown. The cvi_update command automates this.

1 Like

Thanks a lot.

Then I have two questions:

  1. What kind of a firmware is then there on the flash chip and which cores are available when booted off of that chip?
  2. Which pins did you connect this chip to, so that you were able to flash it from a TF card?

Thank you in advance.

driver:

https://github.com/milkv-duo/duo-buildroot-sdk/releases/download/Duo-V1.1.0/CviUsbDownloadInstallDriver.zip

usb tool:

https://github.com/milkv-duo/duo-buildroot-sdk/releases/download/Duo-V1.1.0/CviBurn_v2.0_cli_windows.zip

i connected the spi chip to spinor1(6,7,8,9) pins because uart0 is already in use on the pins which are shared between spi and uart0.

The files are in the correct folder because it has to upload fip.bin so uboot info shows up on uart0 . When fip.bin is not there nothing happens as mcu will keep resetting. when its in the folder it loads the uboot then after uboot this happens

Start USB downloading…

start usb task!
NOTICE: cvi_usb_hw_init
INFO: waiting for connection …
INFO: detect vbus …
INFO: bulkBufAlloc: 0000000081bd7b40
INFO: cmdBufAlloc: 0000000081bd7d80
INFO: ep0BuffAlloc: 0000000081be4100
INFO: setup_buf: 0000000081bd7fc0
INFO: handler: 0000000081bd8040
INFO: cb0_buf: 0000000081bd8450
INFO: cb1_buf: 0000000081bd84e0
INFO: cb2_buf: 0000000081bd8570
INFO: rsp_buf: 0000000081be4150
INFO: acm_buf: 0000000081bd8600
NOTICE: Overwrite fip_src to FIP_SRC_USB
NOTICE: fip_src 6
NOTICE: bind()
NOTICE: Patch VID 3346
NOTICE: Patch VID 3346
NOTICE: USB enumeration done
NOTICE: connection speed: 3
NOTICE: CVI_USB_REBOOT

on the usb tool side it gives this error

[INFO] Waiting for USB device connection: /
[INFO] found usb device vid=0x3346 pid=0x1000
[ERR] unable to open .\rom
[INFO] update total size: 0 byte
[INFO] USB download complete

for the serial output im using arduino ide. And you have to install serial for it like this

pip install pyusb pyserial

Hi @hannahKobain

  1. The TF card’s fip.bin (with U-Boot and 2nd core config), boot.spinor (Linux kernel and device tree), and rootfs.spinor (root filesystem) are copied to SPI flash. They are built alongside any TF files in the standard manner with the same configuration.
  2. These are the pins (you do not need 5V). They are opposite side from UART pins.
1 Like