Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling for different channels #33

Closed
danielefrigo opened this issue Dec 10, 2018 · 15 comments
Closed

Compiling for different channels #33

danielefrigo opened this issue Dec 10, 2018 · 15 comments

Comments

@danielefrigo
Copy link

Hi
I'm trying to compile hex files for channels different from the default one.
I'm using MySBootloader dev branch and the provided boards.txt

I changed the channel here and the board frequency to 8MHz here.

I then compiled (simply running a Make), no errors, but when I flash the obtained hex file on my Arduino (Pro Mini 3.3V 8MHz) it hangs and I'm not able to upload any sketch.

Thanks in advance for any help or suggestion
Daniele

@guillebot
Copy link
Contributor

I am very interested in your effort. Have you had any advances?

I'm using a different channel because of interference and of course FOTA is not working.

@danielefrigo
Copy link
Author

danielefrigo commented Jan 15, 2019 via email

@guillebot
Copy link
Contributor

Can you share with me your development environment? I don't seem to be able to compile this.

@guillebot
Copy link
Contributor

Forget it. I compiled it already. Let's go testing.

@guillebot
Copy link
Contributor

Holy crap. It's updating. I just changed the (76) channel and it works.

Beats me where it's getting the node id from. Does the bootloader reads from the main sketch? (if so, why isn't reading the rf channel also)

Please @tekka007 a little insight? Thanks

@danielefrigo
Copy link
Author

danielefrigo commented Jan 16, 2019 via email

@guillebot
Copy link
Contributor

guillebot commented Jan 16, 2019 via email

@insidecircuits
Copy link

Could you please describe the steps you did to be able to compile? Do I need to place this folder in some specific location?
I have Arduino installed on ubuntu 16.04 and when I try to run make in the project folder I get:

../arduino/bin-linux64/bin/avr-gcc: not found

@guillebot
Copy link
Contributor

guillebot commented Feb 10, 2019

Just make. You don't have the avr devel tools, which includes avr-gcc

Just install them and it will compile.

Or look at my repo, I compiled all the channels and all the clock frecuencies.

https://github.com/guillebot/MYSensors-Bootloaders

@insidecircuits
Copy link

insidecircuits commented Feb 10, 2019

As far as I can tell I have avr-gcc installed, it came with the arduino installation. Still not working.
What is curious to me is that the script is looking for avr-gcc in some arduino folder. So it expects arduino to be installed..
Thank you for suggesting your pre-compiled hex, just that I am using a custom hardware with the CE and CSN signals on other pins and I want to compile for that.

@guillebot
Copy link
Contributor

You should probably check the PATH variables in the script. Put your avr-gcc path there. I had to change it also.

Check my Makefile and the script I use to compile them all.

Makefile

PROJECT = MYSBootloader

MCU = atmega328p
CLK = ${frecuency}
BAUDRATE = ${baudios}


ISP_PORT = com5
ISP_SPEED = $(BAUDRATE)
ISP_PROTOCOL = stk500v2
ISP_MCU = m328p
ISP_HFUSE = DA
ISP_LFUSE = F7
ISP_EFUSE = 06
ISP_ARGS = -c$(ISP_PROTOCOL) -P$(ISP_PORT) -b$(ISP_SPEED) -p$(ISP_MCU)

BINPATH = /usr/bin/

CFLAGS = -funsigned-char -funsigned-bitfields -DF_CPU=$(CLK) -DBAUD_RATE=$(BAUDRATE) -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -Wall -Wextra -Wundef -pedantic -mmcu=$(MCU) -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" 
LDFLAGS = -nostartfiles -Wl,-s -Wl,-static -Wl,-Map="$(OutputFileName).map" -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -mrelax -Wl,-section-start=.text=0x7800 -mmcu=$(MCU)  


all: clean out

clean:
	- rm *.o
	- rm *.elf
	- rm *.hex

$(PROJECT).o: $(PROJECT).c
	"$(BINPATH)avr-gcc" -I"/usr/avr/sys-root/include/" $(CFLAGS) $< -o $@

$(PROJECT).elf: $(PROJECT).o
	"$(BINPATH)avr-gcc" $(LDFLAGS) -o $@ $< -lm
	
$(PROJECT).hex: $(PROJECT).elf
	"$(BINPATH)avr-objcopy" -O ihex -R .eeprom $< $@ 

out: $(PROJECT).hex
	"$(BINPATH)avr-size" $(PROJECT).elf

load: clean out isp

isp: $(PROJECT).hex
	"$(BINPATH)avrdude" $(ISP_ARGS) -e -u -Ulock:w:0x3f:m -qq -Uefuse:w:0x$(ISP_EFUSE):m -Uhfuse:w:0x$(ISP_HFUSE):m -Ulfuse:w:0x$(ISP_LFUSE):m -Ulock:w:0x0f:m
	"$(BINPATH)avrdude" $(ISP_ARGS) -V -q -s -Uflash:w:$(PROJECT).hex
	"$(BINPATH)avrdude" $(ISP_ARGS)

Multicompile

array=( 16000000L 8000000L 1000000L )

for f in "${array[@]}"
 do
 for i in {1..110}
  do
   sed -e "s/\${channel}/$i/" MYSBootloader.c.original > MYSBootloader.c
   if [ $f == "16000000L" ]
   then
    baudios="115200"
   fi

   if [ $f == "8000000L" ]
   then
    baudios="57600"
   fi

   if [ $f == "1000000L" ]
   then
    baudios="9600"
   fi
   
   echo "Frecuency: $f Channel: $i Baud rate: $baudios"
   sed -e "s/\${frecuency}/$f/" -e "s/\${baudios}/$baudios/" Makefile.original > Makefile
   make
   mkdir compiled
   mv MYSBootloader.hex ./compiled/MYSBootloader.ch$i.$f.hex
  
  done
done

@guillebot
Copy link
Contributor

Just check the latest version. Some user asked me for multiple POWER_LEVELs also.

https://github.com/guillebot/MySensorsBootloaderRF24

I'm using this on an arduino pro mini @8MHz on a non standard channel, RF24_PA_MAX, and works great.

@xreichardx
Copy link

@guillebot Thanks so much for this!

@guillebot
Copy link
Contributor

@guillebot Thanks so much for this!

Thank to @scalz! I'm just compiling.

Good luck

@mfalkvidd
Copy link
Member

With merging #36 I think this issue is resolved. Feel free to reopen if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants