Atmel-8390-WIRELESS-AVR2054-Serial-Bootloader Upload Error - Page 1
Forum section: electronics / beginners

author: vishal
author_rank: Regular Contributor
timestamp: June 13, 2017, 11:48:36 am
content: I have downloaded the Atmel-8390-WIRELESS-AVR2054-Serial-Bootloader_v3_2_0 . After reading the documentation I could successfully upload the bootloader.The MCU is avr-atmega256rfr2.The fuse bits we used areFF,9C,62(as specified in the documentation).After that, i converted the Bitcloud application code in ".elf" to ".srec" .Then I tried to upload the application code using boot loader PC tool.At this time it shows to reset the device.We reset it.After some seconds the PC bootloader raises an error showing "Node cannot be programmed.Exceed try count" ..I tried the same thing through command prompt.What will be the issue?please help.

author: ataradov
author_rank: Super Contributor
timestamp: June 13, 2017, 05:39:16 pm
content: This bootloader is very old and not really maintained. Do you have to use it? If not - use something else. I doubt anyone here will be able to help you, you will have to debug this stuff yourself.

author: vishal
author_rank: Regular Contributor
timestamp: June 14, 2017, 03:03:07 am
content: I need a bootloader to upload the bitcloud application code and don't want to necessarily use this one.Are there any other Atmel's bootloader for supporting avr-atmega256rfrMCU?

author: ataradov
author_rank: Super Contributor
timestamp: June 14, 2017, 03:05:45 am
content: There is one in LwMesh package, for example. But ATmega's are very annoying in a way it supports bootloaders, so if you specifically need BitCloud support, then you better off just debugging that one.

author: vishal
author_rank: Regular Contributor
timestamp: June 14, 2017, 03:12:49 am
content: We are also using Lwmesh_1_2_1 ..In which directory of Lwmesh the bootloader resides?

author: ataradov
author_rank: Super Contributor
timestamp: June 14, 2017, 03:20:23 am
content: Bootloader got removed from v1.2. Here is v1.1.1, and bl is still there.https://www.dropbox.com/s/qoft7d1kavu6u00/lightweight_mesh_stack_v1.1.1.zip?dl=0But it will not work with BitCloud. BitCloud will want flash access functions to make PDS work, and it will expect them located in a specific way.

author: vishal
author_rank: Regular Contributor
timestamp: June 14, 2017, 03:26:38 am
content: Thank you so much ataradov.We dont need to necessarily burn bitcloud.Lwmesh is enough.We haven't seen any documentation for how to use this bootloader.

author: vishal
author_rank: Regular Contributor
timestamp: June 14, 2017, 01:10:46 pm
content: I referredhttp://www.avrfreaks.net/forum/lightweight-mesh-otauhttp://www.avrfreaks.net/sites/default/files/OTA%20Upgrade%20Guide.pdf.Added support for avr-atmega256rfr2MCU(linker).I could compile the bootloader.c file for avr-atmega256rfr2.Then I uploaded the bootloader image with fuse bitsFF,1C,E2.After that I tried to load WSNDemo.elf file using the commandpython otaServerDemo.py -d -p COM4 -a 0x8555 -t 0x0010 WSNDemo.elf.But I am getting the following error:Port : COM4Baudrate : 38400Server : 0x8555Client : 0x0010PAN ID : 0x1234Channel : 15 (0x0f)Firmware : WSNDemo.elfFirmware size: 1483276 bytes-> UART_COMMAND_COMM_CHECKError:response timeout.What will be the reason for it?please help

author: ataradov
author_rank: Super Contributor
timestamp: June 14, 2017, 04:58:26 pm
content: What are you trying to do? This is an OTA server, not a bootloader utility. It also takes raw binary files, not ELF files.There is no script for the bootloader itself, it uses Xmodem protocol, so any terminal program that can send files over Xmodem will upload a file (again, raw binary only).

author: vishal
author_rank: Regular Contributor
timestamp: June 15, 2017, 04:27:05 am
content: Thanks .After loading the bootloader I tried to load a WSNDemo.bin file using an extraPutty terminal which supports Xmodem protocol.But I couldn't upload the image.I read thatQuoteI reset the device before sending file from extraPutty.But when I click send button the terminal waits for some time and exit.I am attaching the bootloader code of the atmega256rfr2 image.Why it happens so?

author: ataradov
author_rank: Super Contributor
timestamp: June 15, 2017, 04:35:54 am
content: Do you see letters 'C' in a terminal? That's the first step to debugging.I really don't know off the top of my head. AVR is a really bad architecture for devices with large memory size. I switched to ARM and now my life is good again.

author: vishal
author_rank: Regular Contributor
timestamp: June 15, 2017, 04:38:56 am
content: Quote from: ataradov on June 15, 2017, 04:35:54 amI am not getting letters 'C' .. I reset the device after connecting the device to serial terminal and before sending file.Is that correct.

author: ataradov
author_rank: Super Contributor
timestamp: June 15, 2017, 04:41:21 am
content: Your code indicates PE0 as a boot entry pin. You need to pull that low and reset the device. This will requires a bootloader, and it will start sending letters 'C'. No need for any further resets.

author: vishal
author_rank: Regular Contributor
timestamp: August 25, 2017, 11:55:17 am
content: Hi ,I could successfully uploaded the booloader.After that I tried to load application.For this I compiled WSNDemo application for a coordinator and loaded WSNDemo.bin using ExtraPutty with Xmodem protocol.No error has shown while loading the application.But When I tried to connect it to a serial terminal its only showing 'C'.We expected to display the coordinator name as "coordinator."Why it happens so.please reply.I am using avr-atmega256rfr2MCU The Code bootloader.c and Makefile also attached

author: ataradov
author_rank: Super Contributor
timestamp: August 25, 2017, 06:13:34 pm
content: You are clearly still in bootloader mode, check that your boot entry condition is false after image upload. Also read out the resulting image and see if anything was written into the flash. Basically debug your stuff, I can't do that remotely.

author: vishal
author_rank: Regular Contributor
timestamp: August 26, 2017, 04:11:18 am
content: Hi,I debug it and i could see that the booloader entry section is has not become false after WSNDemo.bin upload.since I chnaged the code from 128rfr1 to 256rfr2 i am confused wther any buffer or configuration is missing for it.Thats why I attached the files too.The sectionCode:if (0 == (status & ((1 << FE1) | (1 << DOR1) | (1 << UPE1)))){return true;}returns true .but after that any of the condition inCode:if (XMODEM_EOT == buf){timeout = 0;handle_buffer();send(XMODEM_ACK);return;}}if (0 == ptr)continue;crc = get_crc();if (XMODEM_SOH == buf && (uint8_t)seq == buf && 0xff == (buf + buf) &&(buf == (uint8_t)(crc >> 8)) && (buf == (uint8_t)(crc))){handle_buffer();seq++;send(XMODEM_ACK);}else{flush();send(XMODEM_NAK);}not working.Simply returns to bootloader mode again.

author: ataradov
author_rank: Super Contributor
timestamp: August 26, 2017, 04:14:17 am
content: Entry section is sampling of the external pin. The code you shown here is just a part of the Xmodem protocol that has noting to do with entry.Jut remove your active entry signal from the pin.

author: vishal
author_rank: Regular Contributor
timestamp: August 26, 2017, 05:05:52 am
content: We removed the active entry signal on PE0 after images is uploaded and it exit from the bootloader mode.But it does not start the application.What may be the mistake with us.

author: ataradov
author_rank: Super Contributor
timestamp: August 26, 2017, 05:34:31 am
content: Have you checked that application was actually uploaded? Read out the device flash, and compare with what you have actually tried to upload.There are only 2 ways bootloader can run - though explicit request or as a fall-trough if there is no application.

author: vishal
author_rank: Regular Contributor
timestamp: August 26, 2017, 07:33:52 am
content: Quote from: ataradov on August 26, 2017, 05:34:31 amI read out the device flash, the application was not uploaded successfully.But when i upload the code extra putty is not showing any error.What will the reason for this upload failure.Anyhow, I am debugging the code.But little confused whether it's because of hardware issue or bootloader issue.I tested the same application without bootloader and it worked

author: ataradov
author_rank: Super Contributor
timestamp: August 26, 2017, 09:02:37 am
content: This clearly has nothing to do with the application, since bootloader fails to write received data into the flash. You need to debug that. Just manually call write_page() and see if does anything. And tweak it until it does.It may be related to EIND usage. I really don't remember any of this, I moved on to sane architectures, and it has been a long time since I did anything with AVR.

author: vishal
author_rank: Regular Contributor
timestamp: August 29, 2017, 10:15:00 am
content: Quote from: vishal on August 29, 2017, 10:13:55 am

author: ataradov
author_rank: Super Contributor
timestamp: August 29, 2017, 11:20:55 am
content: If you want help, decode fuse settings, I have no idea what those numbers mean in human language.You should probably try examples from avr-libc and see if they work. Comment out all the Xmodem stuff and just make sure you can write a single page.I really have no idea and without trying on a real hardware, I would not be able to tell what is wrong. And I don't have any real m256RFR2 hardware or programmers at the moment.

author: vishal
author_rank: Regular Contributor
timestamp: August 29, 2017, 11:51:32 am
content: Quote from: ataradov on August 29, 2017, 11:20:55 amCode:BODLEVEL - 1 v8OCDEN - EnableJAGEN - EnableSPIEN - EnableWDTON - DisableEESAVE - DisableBOOTSZ - 1024w-1FC00BOOTRST - EnableCKDIV8 - DisableCkout - DisableCKSEl-SVT - INTRCOSL-6CK-65MsThese are the fuse settingsQuoteI will try this.Also I strated the work by refering this linkhttp://www.avrfreaks.net/forum/lightweight-mesh-otau]http://www.avrfreaks.net/forum/lightweight-mesh-otau]http://www.avrfreaks.net/forum/lightweight-mesh-otau

author: vishal
author_rank: Regular Contributor
timestamp: August 30, 2017, 04:03:59 am
content: It Worked.In linker script i had writtenCode:MEMORY{text (rx) : ORIGIN=0x00000000, LENGTH =256K-2Kboot (rx) : ORIGIN=0x0003f800, LENGTH=2Kdata (rw!x): ORIGIN=0x00800190,LENGTH=32K-500}Then I modified this with followingCode:MEMORY{text (rx) : ORIGIN = 0x0003f800,LENGTH=2Kboot (rx) : ORIGIN=0x0003fffc,LENGTH=4data (rw!x) : ORIGIN=0x00800190,LENGTH=16K-500}With this It worked.I could load the application with bootloader.Noow I am trying to work on over the air upgrade.What are the necessary changes to make it work for avr-atmega256rfr2 rcb.I found it has only support for atmega128.Can I adopt the same withmodification for avr-atmega256rfr2?

author: ataradov
author_rank: Super Contributor
timestamp: August 30, 2017, 04:30:59 am
content: If we are talking about LwMesh OTA, then no changes should be necessary as far as I remember. It will take any file you give it.

author: vishal
author_rank: Regular Contributor
timestamp: August 30, 2017, 04:52:22 am
content: Quote from: ataradov on August 30, 2017, 04:30:59 amyes the same .I have woked OTA but am getting the following error->UART_COMMAND_COMM_CHECKError:response timeout.Why it so?

author: ataradov
author_rank: Super Contributor
timestamp: August 30, 2017, 05:10:17 am
content: Are you running OTA server application? Check your serial port connections.

author: vishal
author_rank: Regular Contributor
timestamp: August 30, 2017, 05:26:12 am
content: Quote from: ataradov on August 30, 2017, 05:10:17 amyes I am running OTA Server application.After connecting the OTAServer board to COM port I run the followingpython otaServerDemo.py -d -p COM2 -i 0x1234 -c 15 -a 0x8555 -t 0x0000 C:\Users\demo\LwMesh_1_1_1\apps\WSNDemo\make\Debug\WSNDemo.bin.But i am getting "response time out error".I have chnged makefile for avr-atmgega256rfr2 and it compiled.Do I need to specify anythng for avr-atmgega256rfr2 in any of the configuration

author: ataradov
author_rank: Super Contributor
timestamp: August 30, 2017, 05:34:53 am
content: You need to debug the whole system and figure out why Python commands are not getting into the OTAServer application and/or why it is not responding.Put a breakpoint in the UART receive callback and check that your command is getting to the application.

author: vishal
author_rank: Regular Contributor
timestamp: August 30, 2017, 12:46:07 pm
content: HiI could successfully sent file .I got messageOTA_UPGRADE_COMPLETE_STATUSblock sentfile sent.....But the modified code hasn't restarted in the other device.What will be the reason.I used same fuse settings for otaServer and otaClient.Also clock freaquency is 8000000.

author: ataradov
author_rank: Super Contributor
timestamp: August 30, 2017, 01:08:34 pm
content: OTA Server is just an application, it does not need to boot from the bootloader, if you don't actually have a bootloader.First of all check that file is actually received and saved. New image is stored at the offset defined by STARTING_ADDRESS = (SYS_DEVICE_SIZE / 2).Also check that SYS_DEVICE_SIZE is defined correctly, but things would not really work this far if it was not.If image is stored in the flash, then check that appSwitch(); gets called.

author: vishal
author_rank: Regular Contributor
timestamp: August 30, 2017, 01:22:59 pm
content: Quote from: ataradov on August 30, 2017, 01:08:34 pmI used this to transfer the file not added with bootloader.I run this as a seperate applicationQuoteI defined the followingCode:#define SYS_DEVICE_SIZE 262144#define SYS_PAGE_SIZE 256#define SYS_BOOTLOADER_SIZE 2048

author: vishal
author_rank: Regular Contributor
timestamp: August 31, 2017, 10:13:22 am
content: Quote from: ataradov on August 30, 2017, 01:08:34 pmyes the appSwitch() is gets called.but it doesnot start the new application.I defined the SYS_DEVICE_SIZE to value 262144.Is it because of iap_address error.If So what else value can i define.please help

author: ataradov
author_rank: Super Contributor
timestamp: August 31, 2017, 11:20:39 am
content: The device size value is correct, but those 4 bytes reserved at the end are for pointers, and this is not enough for storing 2 pointers for a 256k device.Can you send a flash image with received image (after the upload is done)?I'm not sure how your image is written with truncated pointers like that.In general, iapswitch does nothing by itself, it just jumps up the bootloader, which does the actual work. You need to trace execution there.

author: vishal
author_rank: Regular Contributor
timestamp: September 01, 2017, 06:13:14 am
content: I am debugging the code.Will send the flash image after that.

author: vishal
author_rank: Regular Contributor
timestamp: September 15, 2017, 08:00:36 am
content: Hi.I couldn't get it success.while debugging i could see that the appSwitch() is get called.but from there the fuction iap_switch_handler(); hasn't called.The otainterface file is attached with this .please check if anythng needed to add.The flas image of the device also attached.

author: ataradov
author_rank: Super Contributor
timestamp: September 15, 2017, 08:06:48 am
content: As I said earlier, it is related to the fact that .boot.write_page and .boot.switch are 2 bytes long, and they need to be 4 bytes long. And you many need to mess with EIND when calling them as well. AVR past 128K is really messy and stupid.

author: vishal
author_rank: Regular Contributor
timestamp: September 15, 2017, 08:13:51 am
content: Quote from: ataradov on September 15, 2017, 08:06:48 amSorry to ask.Where can I mention the .boot.write_page and .boot.switch.i havent seen any place othar than thisCode:__attribute__((section(".boot.write_page"))) void iap_write_page_handler(uint32_t addr, uint16_t *buf);__attribute__((section(".boot.switch"))) void iap_switch_handler(void);

author: ataradov
author_rank: Super Contributor
timestamp: September 15, 2017, 08:14:46 am
content: In the linker script on both application and bootloader side.

author: vishal
author_rank: Regular Contributor
timestamp: September 15, 2017, 08:21:50 am
content: This is my linker script.can you please help me to set this value in this file

author: ataradov
author_rank: Super Contributor
timestamp: September 15, 2017, 08:26:22 am
content: So their size is defined by the natural size of the pointer for that platform. And I don't know if it is 2 or 4 bytes - look in the binary.Also just step though that code calling the switch function in the disassembly mode and check what exactly it is doing and how to fix it to do the right thing.I really don't know/remember without doing all of this myself. And I'm not going to do that, I moved from AVRs for good and have no desire to touch them ever again.

author: vishal
author_rank: Regular Contributor
timestamp: September 15, 2017, 09:10:12 am
content: Can We assign this in the linker itself without refering the natural size.

author: ataradov
author_rank: Super Contributor
timestamp: September 15, 2017, 09:11:48 am
content: The problem is that if size is 2, then you need to manually manage EIND no matter what. There is only one way to know - run it under the debugger and see what is going wrong.

author: vishal
author_rank: Regular Contributor
timestamp: September 16, 2017, 08:57:53 am
content: I debug the code and I could see that all call to all function working correctly.But the new application is not restarted in the device.I know u are not working in avr now.why the new application is not started in address specified is still unknown.Am not getting any error .The code works fully without any trouble. It may be because of the size issue .I have changed the those size values to some large.but no use.I am really stuck in updating the firmware.Please help me to fix it

author: ataradov
author_rank: Super Contributor
timestamp: September 16, 2017, 02:49:07 pm
content: Quote from: vishal on September 16, 2017, 08:57:53 amSo do you end up in the bootloader after the switch called in the application?Can you send me a device memory dump after the upgrade (even failed one)?

author: vishal
author_rank: Regular Contributor
timestamp: September 19, 2017, 04:21:17 am
content: Quote from: ataradov on September 16, 2017, 02:49:07 pmam attaching the device memory dump.

author: ataradov
author_rank: Super Contributor
timestamp: September 19, 2017, 04:23:03 am
content: That's a very short dump consisting of all 0xff.Yes, it is 8K, so it look like a dump of the EEPROM. I need the dump of the flash memory (all 256K).

author: vishal
author_rank: Regular Contributor
timestamp: September 19, 2017, 04:34:02 am
content: Here is the device flash image.

author: ataradov
author_rank: Super Contributor
timestamp: September 19, 2017, 04:39:14 am
content: This file has no second image, so your write function does not work either (to be expected, really).You need to figure out that mechanism, where application must call a function located in the bootloader. This is a key thing here, and no matter what you do, you won't be able to avoid debugging it.

author: vishal
author_rank: Regular Contributor
timestamp: September 19, 2017, 06:03:06 am
content: Hi,The status message after the file transfer is attached .I couldnt see any function in the application which calls the bootloader.c file.All those OTA upgrade only has dependency to OTAClient.c and OTAInterface.c.Also,the write page fucntions written in OTAInterface.Is that enough for the fucntioning?

author: ataradov
author_rank: Super Contributor
timestamp: September 19, 2017, 06:11:36 am
content: It does not matter what that script says at this point.OTA interface contains calls to two functions located in the bootloader - IAP_WRITE_PAGE_HANDLER and IAP_SWITCH_HANDLER. appGetIapHandler() is used to retrieve actual pointers. The problem is that it only reads words, which is enough on 128K devices, and not enough on 256K devices.You need to figure out if standard C pointer is 2 or 4 bytes on that platform.Basically forget about full OTA stuff for now. Just call appSwitch() anywhere from the application, and make things work so that iap_switch_handler() is called in the bootloader. Just called, it does not have to actually do anything, just blink an LED or something.Once that works, the rest will work automatically.It is a pretty short path in assembly, you should be able to easily trace it. If you can't, you should consider hiring someone to do this.

author: vishal
author_rank: Regular Contributor
timestamp: September 19, 2017, 09:10:43 am
content: Quote from: ataradov on September 19, 2017, 06:11:36 amappSwitch () and iap_switch_handler() is working..No doubt in it.If it works then why the application not restarted?QuoteappGetIapHandler() didnt see in any of the fileQuoteThis one i am confused.Where it is specified as 2 or 4 byte.

author: ataradov
author_rank: Super Contributor
timestamp: September 19, 2017, 09:13:26 am
content: Quote from: vishal on September 19, 2017, 09:10:43 amCan you elaborate how do you know it? I don't see how it can work with your current code.Quote from: vishal on September 19, 2017, 09:10:43 amIt is the first function in the otaInterface.c file.Quote from: vishal on September 19, 2017, 09:10:43 amEither compiler documentation or experiment.

author: vishal
author_rank: Regular Contributor
timestamp: September 19, 2017, 09:28:45 am
content: Quote from: ataradov on September 19, 2017, 09:13:26 amPlease have a look at following otaInterface.Am using otainterface for atmega256 device.Am attaching both 128 and 256 otaInterface file.and am working on otaInterface for avr256.In that the function is missing.Can you check wthethr the file am using is correct or not

author: ataradov
author_rank: Super Contributor
timestamp: September 19, 2017, 04:24:38 pm
content: That is not how those files look in the latest stack version to include OTA.I'm not sure where yours came from, I can't see a single version where it was like this.

author: vishal
author_rank: Regular Contributor
timestamp: September 20, 2017, 03:14:03 am
content: Quote from: ataradov on September 19, 2017, 04:24:38 pmWhere Can I get the latest version.I have worked on LwMesh_1_1_1 and LwMesh_1_2_1 and bootloader is provided with LwMesh_1_1_1 .and I got otaInterface.c file for avr-atmega256 from the following referencehttp://www.avrfreaks.net/comment/925251#comment-925251

author: ataradov
author_rank: Super Contributor
timestamp: September 20, 2017, 03:22:09 am
content: LwMesh_1_1_1 contains the file I included. It is also your 128K file.The thing is, both files are correct for both cases. Either of them will work, but you need to match what bootloader provides and what application expects. And standard bootloader is designed for the 128K style. You either need to change your application or bootloader.You really need to understand how all this works. You can't make it work by pulling random bits form the internet.

author: vishal
author_rank: Regular Contributor
timestamp: September 20, 2017, 04:03:01 am
content: My understanding is if we use default boot loader and application we should need to1)program the bootloader2)transfer the application using serial port3)then further application modification is done via OTA using otaServer.But what are the steps to follow if the booloader function is inclued in application itself.

author: ataradov
author_rank: Super Contributor
timestamp: September 20, 2017, 04:06:26 am
content: It is not about the steps. It is about how application talks to the bootloader.You need to figure out a way to place a function that blinks an LED in the bootloader section and call that function from the application. However you do that is not important.In the second option (your 256K file), function are located at fixed addresses. You still need a "bootloader" that contains those functions. There is no serial port stuff in that case. You will have to combine bootloader and application image manually (using some python script or whatever works for you).

author: vishal
author_rank: Regular Contributor
timestamp: September 20, 2017, 06:27:02 am
content: Quote from: ataradov on September 20, 2017, 04:06:26 amyes.I tried such function and called it from application ..nothing has happened.First of all i programmed bootloader and initial image is loaded via serial port.That worked.Now my device have bootloader and initial image of application i suppose.Also I tried to see wthethr appSwitch() function is worked or not for OTA .That one also not worked.So I think my device have bootloader and application but while using OTA its not calling any of the function in bootloader.Do we need to specify anythng to make this function work.

author: ataradov
author_rank: Super Contributor
timestamp: September 20, 2017, 06:30:49 am
content: Quote from: vishal on September 20, 2017, 06:27:02 amI'll say it one more time and I'm out of here.You need to understand what are you doing and what is missing. You've got enough information to do this. Just take time to actually do it. I can't teach you programming in a forum thread.Use the debugger and singe step though the program to see what is happening and what needs to happen.

author: vishal
author_rank: Regular Contributor
timestamp: September 20, 2017, 06:33:19 am
content: okay I will try ...Thank you so much for your great support.It was really helpful.I understood the basic facts .. Will try.

author: vishal
author_rank: Regular Contributor
timestamp: September 27, 2017, 12:47:30 pm
content: Hi, I start it from the beginning. and I have done the following1)I uploaded bootloader.2)have loaded the initial image via serial interface3)Tried OTAWhile debugging I found that the appSwitch() function is not calledIn OtaInterface.c the following lines of code is not workingCode:else if(OTA_UPGRADE_COMPLETED_STATUS==status){appWritePage();appSwitch();appUpgradeInProgress=false;}and I have seen in otaclient.c the above lines get invoked when calling the following.but that one also not become true .it shows that 0 !=otaclient.sizeCode:void OTA_ClientBlockConfirm(OTA_Status_t status){if(OTA_SUCCESS_STATUS==status && 0 ==otaclient.size){otaclientSendResponse(OTA_UPGRADE_COMPLETED_STATUS)}}Two blocks are written and after it shows "Error: unexpected status (OTA_NO_RESPONSE_STATUS)"..In one of the forum i read this error is because there is no bootloader.but in my case i have the bootloader and i could upload application via serial terminal.Also you have mentioned several times about 4-byte (size) for avr-atmega256rfr2.Where can I check it and where I can I change it.I am using avr-gcc to compile.do it hav dependency.Kindly reply .

author: ataradov
author_rank: Super Contributor
timestamp: September 27, 2017, 03:33:17 pm
content: Forget about switch. Make sure that normal pages are written.C pointer is 4 bytes on m256, check the size of the C pointer.

author: vishal
author_rank: Regular Contributor
timestamp: September 28, 2017, 04:49:21 am
content: Before checking it i have one more doubtMy linker scrpit is attached here with and I changed the following lines in bootloader.cCode:__attribute__((section(".iap.write_page"))) void (*iap_write_page)(uint32_t, uint16_t *) = iap_write_page_handler;__attribute__((section(".iap.switch"))) void (*iap_switch)(void) = iap_switch_handler;toCode:__attribute__((section(".boot.write_page"))) void iap_write_page_handler(uint32_t addr, uint16_t *buf);__attribute__((section(".boot.switch"))) void iap_switch_handler(void);Is there any error with this lineWhile compiling with this change it shows the error "lf section `.boot' will not fit in region `boot'"..how can I change the memroy value to fit the boot section

author: ataradov
author_rank: Super Contributor
timestamp: September 28, 2017, 04:57:24 am
content: Region 'boot' is declared as 4 bytes in size.

author: vishal
author_rank: Regular Contributor
timestamp: September 28, 2017, 11:14:07 am
content: Quote from: ataradov on September 28, 2017, 04:57:24 amI solved it by incresing the size from 4 to 264.now the boot section fit in to the memory.Quote from: ataradov on September 27, 2017, 03:33:17 pmI cant write the normal pages.The flash image of the device is attachedQuoteWhere can I see the size.Is it in the linker script or its depend on compiler?

author: ataradov
author_rank: Super Contributor
timestamp: September 28, 2017, 03:09:36 pm
content: Quote from: vishal on September 28, 2017, 11:14:07 amGoogle it, or compile a simple program and see hoe big the pointer is.But with your new bootloader approach, it does not matter. All you need to do now is use the same script for the application, and may be a bit debugging. With this approach compiler should figure out how to execute those functions.Forget about writing flash. Make sure that you can reliably call function from the application to the bootloader.

author: vishal
author_rank: Regular Contributor
timestamp: September 29, 2017, 02:55:59 am
content: Quote from: ataradov on September 28, 2017, 03:09:36 pmIf I want to write a function to blink an led ; I write the function in bootloader.c .then how can I call it from application..Is it in the same way that IAP_SWITCH_HANDLER and IAP_WRITE_PAGE_HANDLER in otaInterface.c .

author: ataradov
author_rank: Super Contributor
timestamp: September 29, 2017, 02:57:25 am
content: Yes. It is exactly the same. The exact details depend on which version of the linker script you are using.

author: vishal
author_rank: Regular Contributor
timestamp: September 29, 2017, 03:05:07 am
content: IAP_SWITCH_HANDLER defines (SYS_DEVICE_SIZE -4) .Is it the memory loaction that the funcion points to?.If I have BLINK_LED what should it defines? Do we need to care anythng in function naming(i,e to use the same name in boot loader and otainterface).

author: ataradov
author_rank: Super Contributor
timestamp: September 29, 2017, 03:07:02 am
content: That is a location of a pointer to a function inside the bootloader. This is not what you want for your last linker script.But I don't get how you can continue like this without trying to do any investigation on your own. I will not teach you how to debug things, there are plenty of tutorials on this.

author: vishal
author_rank: Regular Contributor
timestamp: September 29, 2017, 08:29:31 am
content: Quote from: ataradov on September 29, 2017, 03:07:02 amSorry, Actually I am not well aware of the linker script.I know here its used to link bootloader and application.But what address should be given and how it depends on the application is unknown.I am debugging the OTA client and OTA interface to see what part works and doesn't.

author: ataradov
author_rank: Super Contributor
timestamp: September 29, 2017, 04:11:05 pm
content: Quote from: vishal on September 29, 2017, 08:29:31 amIt is time to learn.Quote from: vishal on September 29, 2017, 08:29:31 amLinker script is just an instructions on where to put things on the memory. You need to understand what things you put there and where, and then it will be obvious how to make them work.Quote from: vishal on September 29, 2017, 08:29:31 amYou should know it, you are designing the application, it is up to you do define that.

author: vishal
author_rank: Regular Contributor
timestamp: October 16, 2017, 06:18:43 am
content: Hi,As you said i tried to blink and LED in iap_write_page() function of bootloader section from application.For this I called appWritePage() from application(the control in turn goes to iap_write page()). Also added the led blinking code in iap_write_page() function. In linker script of bootloader I haveCode:MEMORY{text (rx) : ORIGIN = 0x0003f800, LENGTH = 256K-2Kboot (rx) : ORIGIN = 0x0003fffc, LENGTH = 2Kdata (rw!x) : ORIGIN = 0x00800190, LENGTH = 32K-500}Also In script the boot section is like thisCode:.boot :{*(.boot.switch)*(.boot.write_page)KEEP(*(.boot.*))} > bootWhen I used ALIGN(256) it showed error that the address not fit in range.In bootloader.c I definedCode:__attribute__((section(".boot.write_page"))) void (*iap_write_page)(uint32_t, uint16_t *) = iap_write_page_handler;__attribute__((section(".boot.switch"))) void (*iap_switch)(void) = iap_switch_handler;Also in created led.h file I have definedCode:#define STARTING_ADDRESS (SYS_DEVICE_SIZE / 2)#define IAP_SWITCH_HANDLER (SYS_DEVICE_SIZE - 4)#define IAP_WRITE_PAGE_HANDLER (SYS_DEVICE_SIZE - 2)here SYS_DEVICE_SIZE =262144 .So IAP_SWITCH_HANDLER points to 3fffc.I added LED blinking code in both iap_write_page_handler and iap_switch_handler.but nothing worked.please clarify me the following1) Do I need same linker script in application(tried with one but no use)2)Do I need to specifyCode:.boot :{. = ALIGN(256);*(.boot.switch). = ALIGN(256);*(.boot.write_page)KEEP(*(.boot.*))} > bootIf so i have to adjust iap address..Kindly suggest a solution

author: ataradov
author_rank: Super Contributor
timestamp: October 16, 2017, 06:21:40 am
content: I will only answer once you explain to me the purpose of the ". = ALIGN(256);" statements. If you still don't understand it, you need to do more reading and experiments with linker scripts. Without this, the whole thing is a waste of time.

author: vishal
author_rank: Regular Contributor
timestamp: October 16, 2017, 06:33:53 am
content: ALIGN aligns the section to a particular boundary.here 256 bytes allocated for each of the iap functions.I havent see in other linker script(atmega128rfr1) to align this section.If I have to use this I need to adjust iap address.thats why get confused

author: ataradov
author_rank: Super Contributor
timestamp: October 16, 2017, 06:36:30 am
content: Well, can you answer your own question whether you need them here or not?You will have to look at disassembler output and trace execution of the code. There is no way to avoid this. And once you see what actuall happens on hardware level, you will know what you need to change.

author: vishal
author_rank: Regular Contributor
timestamp: October 25, 2017, 10:15:35 am
content: Hi,I started to debug.While debugging I found that the OTAclient response data is not arriving at OTA server.But in OTAclient it sends.but nothing hit in otaServerDataInd().I understood only after getting OTA_SUCCESS_STATUS from the client to server it starts to send blocks of bytes to upgrade.Here the initial OTA_SUCCESS_STATUS is not receiving and execution end after exceeding maximum try count.Checked the hardware with peer to peer code.both devices send and receive.no issue.but here client response is not hitting in server.The client can receive from the server.

author: ataradov
author_rank: Super Contributor
timestamp: October 25, 2017, 04:56:47 pm
content: As I said numerous times, forget about OTA and files and LwMesh for now. Make two projects. One is a bootloader that contains certain function you need to call. The other one is a simple main() that calls that function. That's all you need to do now. That's how you debug.

author: vishal
author_rank: Regular Contributor
timestamp: October 26, 2017, 05:10:21 am
content: Yes..I did it.I wrote a blinkLED() in bootloader.c and called it from application.it worked.In bootloader.c i haveCode:__attribute__((section(".boot.blink")))void(*blink_led)(void)=blinkLED;void blinkLED(){for(uint8_t i=0;i<10;i++){DDRD|=(1<<6);PORTD|=(1<<6);_delay_ms(100);PORTD&=~(1<<6);_delay_ms(100);}in application i haveCode:static void *appGetIapHandler(uint32_t addr){void *handler;#if defined(__ICCAVR__)memcpy_P((void *)&handler,(void const __farflash*)addr,sizeof(void *));#elsehandler=(void *)pgm_read_word_far(addr);#endifreturn handler;}static void blink_led(void){blinkled_t blink=(blinkled_t) appGetIapHandler(BLINK_LED);ATOMIC_SECTION_ENTEREIND=1;blink();EIND=0;ATOMIC_SECTION_LEAVE}It worked.

author: ataradov
author_rank: Super Contributor
timestamp: October 26, 2017, 05:18:59 am
content: Ok, good.The only thing to check is that APP_OTA_ENDPOINT is the same on both sides. Otherwise - debug.But if I remember correctly, you have this part working already. What happened to that?

author: vishal
author_rank: Regular Contributor
timestamp: October 26, 2017, 05:24:30 am
content: APP_OTA_ENDPOINT is set as 2 on both sides. Now the issue in the initial OTA_SUCCESS_STATUS not receiving in the otaserver....Also i tested to send some data to the server to see wther anythng hit in otaServerDataInd().but nothing is getting there.Hope that if it solved all other thing works.

author: ataradov
author_rank: Super Contributor
timestamp: October 26, 2017, 05:27:46 am
content: What "initial OTA_SUCCESS_STATUS"? This OTA is a request-response. What request is not getting answered?

author: vishal
author_rank: Regular Contributor
timestamp: October 26, 2017, 05:30:29 am
content: The server is not getting any response from client.But the client can receive request and it sends response.That response not receiving in the server

author: ataradov
author_rank: Super Contributor
timestamp: October 26, 2017, 05:32:02 am
content: What are the parameters of the NWK_DataReq_t that client uses to send the response, and what status code it receives in the confirmation handler?

author: vishal
author_rank: Regular Contributor
timestamp: October 26, 2017, 06:28:30 am
content: It returns NWK_NO_ROUTE_STATUS(0x11).The parametrs set areCode:otaDataReq.srcEndpoint=APP_OTA_ENDPOINT;otaDataReq.dstEndpoint=APP_OTA_ENDPOINT;otaDataReq.options=NWK_OPT_ACK_REQUEST;otaDataReq.dstAddr=otaclient.server;otaDataReq.size=sizeof(OtaStartRespCommand_t)

author: ataradov
author_rank: Super Contributor
timestamp: October 26, 2017, 06:32:47 am
content: I meant actual numerical values, I have the code. Does otaclient.server matches the actual address of the server?I don't know basically, debug. Single step it and see what is failing and where.

author: vishal
author_rank: Regular Contributor
timestamp: October 26, 2017, 06:36:37 am
content: Quote from: ataradov on October 26, 2017, 06:32:47 amCode:otaDataReq.srcEndpoint=2;otaDataReq.dstEndpoint=2;here otaclient.server address is 0x8555.I also tried it by directly giving it as otaDataReq.dstAddr=0x8555;but no use.

author: ataradov
author_rank: Super Contributor
timestamp: October 26, 2017, 06:44:42 am
content: This all looks ok. Having a sniffer would help a lot.Without the sniffer, all you can do is check why route is not found. Looks in the stack routing tables.Also, try to set a different address (like 5) to the server.

author: vishal
author_rank: Regular Contributor
timestamp: October 31, 2017, 05:23:21 am
content: Quote from: ataradov on October 26, 2017, 06:44:42 amI tried but no use with this address change.while debugging the NWK_NO_ROUTE_STATUS appear when we enable the NWK_ENABLE_ROUTE_DISCOVERY in the application.

author: ataradov
author_rank: Super Contributor
timestamp: October 31, 2017, 05:24:29 am
content: Quote from: vishal on October 31, 2017, 05:23:21 amDo you enable this on both sides?

author: vishal
author_rank: Regular Contributor
timestamp: October 31, 2017, 05:44:19 am
content: yes, I have enabled it on both sides.

author: ataradov
author_rank: Super Contributor
timestamp: October 31, 2017, 05:45:51 am
content: Well, then you will have to trace why the receiving side does not respond to the route request. It usually just works, so something is broken on your side.You may want to start with a clear version of the stack/application, and apply your changes on top.

author: vishal
author_rank: Regular Contributor
timestamp: October 31, 2017, 06:39:44 am
content: I start it from beginning with a clear stack.Now the error I got is NWK_NO_ACK_STATUS and NWK_PHY_NO_ACK_STATUS

author: ataradov
author_rank: Super Contributor
timestamp: October 31, 2017, 06:41:03 am
content: Your devices appear to have some hardware issues.

author: vishal
author_rank: Regular Contributor
timestamp: October 31, 2017, 06:43:10 am
content: but it will work for basic peer to peer to communication and WSNDemo..So can we confirm it to have hardware issue

author: ataradov
author_rank: Super Contributor
timestamp: October 31, 2017, 06:46:03 am
content: Quote from: vishal on October 31, 2017, 06:43:10 amThose applications perform multiple retries, and generally tolerant to lost data. Run WSNDemo and actually check status codes.It is virtually impossible to get NWK_PHY_NO_ACK_STATUS on working hardware and in a clean environment.

author: vishal
author_rank: Regular Contributor
timestamp: October 31, 2017, 06:59:59 am
content: I checked the hardware again with the basic WSNDemo application.It works fine.and returns NWK_STATUS_SUCCESS code.no issue has found in hardware.Then why i am getting NWK_NO_ACK_STATUS and NWK_PHY_NO_ACK_STATUS in OTA application

author: ataradov
author_rank: Super Contributor
timestamp: October 31, 2017, 07:01:05 am
content: DEBUG! I don't know. I'm not clairvoyant.

author: vishal
author_rank: Regular Contributor
timestamp: November 02, 2017, 07:46:03 am
content: I have had some success. I got bootloader and OTA worked.Thank you so much for your support

author: vishal
author_rank: Regular Contributor
timestamp: November 16, 2017, 06:32:54 am
content: Hi ,Now am trying to modify the bootloader with a small change.instead of checking PE0 pin it should start the application automatically once it's programmed.For this in reboot functionI commented while(1)i.eCode:main(){if(bootloader_mode()){hardware_init();receive_file();reboot();}reset_vector();}The reboot looks like thisCode:static void reboot(void){wdt_reset();WDTCSR=(1<<WDCE) |(1<<WDE);WDTCSR=(1<<WDE);//while(1);}Now I could automatically switch to the application once it programmed.But at that time I completely lost bootloader from the device.Why it so happens.How can I switch to the application automatically by keeping bootloader section as it is?

author: ataradov
author_rank: Super Contributor
timestamp: November 16, 2017, 06:37:48 am
content: You are enabling WDT and then no waiting for it to reset the MCU. Just delete the while reboot function, if you want it to start the application right away. But you may want to bring back the state of all the hardware that bootloader used.None of this should have erased the bootloader though, so I have no idea what else you did wrong.