casanovg / timonel

ATtiny85/45/25 I2C bootloader
MIT License
110 stars 18 forks source link

make-timonel.sh under Linux #22

Open prandeamus opened 3 years ago

prandeamus commented 3 years ago

"make-timonel-sh" doesn't execute under Linux (more properly when I use it from bash shell)

./make-timonel.sh: 40: ./make-timonel.sh: function: not found (then the "Usage text" ./make-timonel.sh: 79: ./make-timonel.sh: Syntax error: "}" unexpected

Problem seems to be line 1 hash-bang

!/bin/sh

If I change this #!/bin/bash, it works

I suspect that your development environment regards bash and sh as functionally equivalent. but for me sh and bash are different executables. Lordy, lordy, I love Unix but how many shells can one operating system need? The documentation says that sh is synonym for dash, but that bash is different. Presumably my sh (dash) doesn't like your function syntax.... argggh. Workaround for me is to edit line 1. as noted above. I'm not really sure what linux best practice is here, and if there some incantation which always picks the right shell? I didn't want to submit a PR not knowing best practice.

As a sanity check, the sample output for ./make-timonel.sh tml-t85-small timonel 13 1B80 1 false is attached below.


RUNNING: make all CONFIG=tml-t85-small TARGET=timonel TIMONEL_TWI_ADDR=13 TIMONEL_START=1B80 LOW_FUSE=0x62 AUTO_CLK_TWEAK=false

======================================================================== Building Timonel configuration: tml-t85-small
TIMONEL_START = 0x1B80 TWI_ADDRESS = 13 "timonel.hex"
======================================================================== ... ENABLE_LED_UI = false ... AUTO_PAGE_ADDR = false ... APP_USE_TPL_PG = false ... CMD_SETPGADDR = true ... TWO_STEP_INIT = false ... USE_WDT_RESET = false ... APP_AUTORUN = false ... CMD_READFLASH = false ... CMD_READDEVS = false ... EEPROM_ACCESS = false
... AUTO_CLK_TWEAK = false
... LOW_FUSE = 0x62
... LED_UI_PIN = PB1

[Sections] text data bss dec hex filename 896 0 198 1094 446 timonel.bin

[Hexfile] Take "data" size to calculate the bootloader's start address! text data bss dec hex filename 0 896 0 896 380 timonel.hex

prandeamus commented 3 years ago

Ignore format messup - output of the script was interpreted as markdown.

casanovg commented 3 years ago

I couldn't come to a definitive conclusion on what the correct hash-bang should be in this case.

I did several tests with "make-timonel.sh" on Fedora and CentOS and using #!/bin/sh or #!/bin/bash seems to be indistinct for this script. Maybe on non-Red Hat-like Linux distros, is not like this.

Given that #!/bin/bash also works fine for Git Bash on Windows, I'll use it everywhere, so this problem, for the moment, could be considered solved this way.

prandeamus commented 3 years ago

That sounds good - for reference I'm using a Ubuntu derivative it belongs to the debian family.