Closed jubeormk1 closed 3 months ago
Allow me to answer myself. I should check the dfmt::println
. That is where the problem came from. Replacing the println
by a log::info compiles and run on the target.
My code is still incorrect since I obtain no response. I must be initialising wrongly by I2C device.
The pin assignment was wrong, once corrected thinks works almost as expected. In this port with extra verbosity we can see correct ID and readings in normal mode and low power. After the sleep instruction there is no way to measure again:
$ cargo run -r
Compiling i2c-playground v0.1.0 (/home/jubeor/repos/esp32/i2c-playground)
Finished `release` profile [optimized + debuginfo] target(s) in 1.25s
Running `espflash flash --monitor target/riscv32imc-unknown-none-elf/release/i2c-playground`
[2024-06-06T11:10:25Z INFO ] 🚀 A new version of espflash is available: v3.1.0
[2024-06-06T11:10:25Z INFO ] Serial port: '/dev/ttyACM0'
[2024-06-06T11:10:25Z INFO ] Connecting...
[2024-06-06T11:10:25Z INFO ] Using flash stub
Chip type: esp32c3 (revision v0.4)
Crystal frequency: 40 MHz
Flash size: 4MB
Features: WiFi, BLE
MAC address: 40:4c:ca:8c:e9:7c
App/part. size: 98,704/4,128,768 bytes, 2.39%
[2024-06-06T11:10:25Z INFO ] Segment at address '0x0' has not changed, skipping write
[2024-06-06T11:10:25Z INFO ] Segment at address '0x8000' has not changed, skipping write
[00:00:00] [========================================] 28/28 0x10000 [2024-06-06T11:10:27Z INFO ] Flashing has completed!
Commands:
CTRL+R Reset chip
CTRL+C Exit
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380630
0x40380630 - esp_hal::interrupt::riscv::vectored::get_configured_interrupts
at /home/jubeor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-hal-0.17.0/src/interrupt/riscv.rs:363
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x1714
load:0x403cc710,len:0x968
load:0x403ce710,len:0x2f9c
entry 0x403cc710
I (24) boot: ESP-IDF v5.1.2-342-gbcf1645e44 2nd stage bootloader
I (24) boot: compile time Dec 12 2023 10:50:58
I (25) boot: chip revision: v0.4
I (29) boot.esp32c3: SPI Speed : 40MHz
I (34) boot.esp32c3: SPI Mode : DIO
I (38) boot.esp32c3: SPI Flash Size : 4MB
I (43) boot: Enabling RNG early entropy source...
I (48) boot: Partition Table:
I (52) boot: ## Label Usage Type ST Offset Length
I (59) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (67) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (74) boot: 2 factory factory app 00 00 00010000 003f0000
I (82) boot: End of partition table
I (86) esp_image: segment 0: paddr=00010020 vaddr=3c010020 size=024cch ( 9420) map
I (96) esp_image: segment 1: paddr=000124f4 vaddr=3fc80e20 size=00004h ( 4) load
I (103) esp_image: segment 2: paddr=00012500 vaddr=40380000 size=00e20h ( 3616) load
I (112) esp_image: segment 3: paddr=00013328 vaddr=00000000 size=0ccf0h ( 52464)
I (131) esp_image: segment 4: paddr=00020020 vaddr=42000020 size=0814ch ( 33100) map
I (139) boot: Loaded app from partition at offset 0x10000
I (139) boot: Disabling RNG early entropy source...
INFO - Starting SHTC3 tests.
INFO - Waking up sensor.
INFO -
INFO - Device identifier: 0x47
INFO - Raw ID register: 0b0000100010000111
INFO -
Normal mode measurements:
INFO - 23.68 °C | 46.10 %RH
INFO - 23.65 °C | 46.10 %RH
INFO - 23.71 °C | 46.00 %RH
INFO - 23.67 °C | 46.06 %RH
INFO - 23.72 °C | 46.07 %RH
INFO - 23.70 °C | 46.07 %RH
INFO - 23.75 °C | 46.11 %RH
INFO - 23.71 °C | 46.09 %RH
INFO - 23.67 °C | 46.09 %RH
INFO - 23.75 °C | 46.09 %RH
INFO -
Low power mode measurements:
INFO - 24.21 °C | 46.28 %RH
INFO - 23.98 °C | 46.23 %RH
INFO - 23.99 °C | 45.99 %RH
INFO - 23.94 °C | 45.99 %RH
INFO - 24.08 °C | 46.22 %RH
INFO - 24.21 °C | 46.37 %RH
INFO - 24.03 °C | 46.45 %RH
INFO - 23.98 °C | 46.32 %RH
INFO - 24.21 °C | 46.53 %RH
INFO - 24.08 °C | 46.12 %RH
INFO -
Testing power management:
INFO - -> Measure:
INFO - Success: 23.76 °C
INFO - -> Sleep
INFO - Sleep command succeeded
INFO - -> Measure:
ERROR - Error: I2c(AckCheckFailed)
INFO - -> Wakeup
ERROR - Wakeup command failed: I2c(AckCheckFailed)
INFO - -> Measure:
ERROR - Error: I2c(AckCheckFailed)
INFO - -> Soft reset
ERROR - Reset command failed: I2c(AckCheckFailed)
INFO - -> Measure:
ERROR - Error: I2c(AckCheckFailed)
I will take a look at the datasheet but I should say that this issue is closed. There was nothing wrong with the crate which is working on no_std, in particular esp32-c3 with rust core library.
Good to see that you found the issue :)
Hello!
Does your crate support no_std?
I am testing your driver with the board esp-rust-board in a public repository
The board that I am using has a esp32-c3 and the project was made using the no-std esp-template
Apart from that in the entry function I have created a delay instance, an embedded_hal I2C device and a ShtCx (shtcx::shtc3) following your example on shtc3.
When I compile I am receiving the next output where it looks like Looks like _defmt_timestamp, _defmt_write, _defmt_release, and _defmt_acquire are not defined:
Any ideas?