tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
14.81k stars 872 forks source link

DHT11 can't compile in arduino #4111

Closed MushiTheMoshi closed 5 months ago

MushiTheMoshi commented 5 months ago

Hi there,

First of all , thank you for all the amazing work done here, appreciated.

I have an arduino uno which have connected a dht11 humidity sensor, when compiling get the below error.

Hope you can help to point me in the right direction.

CMD:
**❯ tinygo flash --target=arduino drivers/examples/dht/main.go --error-limit=0**

ERR:
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 82 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 152 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 168 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 208 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 220 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 552 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 730 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 892 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 1214 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 1294 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 1304 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 1332 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2322 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2368 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2380 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2400 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2534 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2546 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2612 bytes
tinygo:ld.lld: error: section '.text' will not fit in region 'FLASH_TEXT': overflowed by 2762 bytes
tinygo:ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
failed to run tool: ld.lld
error: failed to link /tmp/tinygo2416875419/main: exit status 1
tinygo version 0.30.0 linux/amd64 (using go version go1.20.4 and LLVM version 16.0.1)
go version go1.20.4 linux/amd64 <<<tried with other versions
aykevl commented 5 months ago

The example imports fmt, which is too big to be usable on an AVR. I suggest using a simpler program that just calls println instead.

Closing, because this is not a bug.

MushiTheMoshi commented 5 months ago

Thank you so much for your help! quick question, how can I troubleshoot this? any tool/command I may use in the future you can kindly suggest me ?

aykevl commented 5 months ago

In this case it says the flash area is overflowed, which indicates that the binary is too big. Which essentially means you need to reduce the size. There's no specific tool for anything like this I'm afraid.