Skip to content

Dual flash and Hex file support on NCS36510 #4397

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

Closed
wants to merge 5 commits into from

Conversation

pradeep-gr
Copy link
Contributor

Description

Dual flash and Hex file support added

Status

READY

Related PRs

https://github.com/maclobdell/FlashAlgo/pull/2
https://github.com/maclobdell/DAPLink/pull/9

Deploy notes

Build output will be hex file. Post build script will insert FIB, User trim and trims gap.
Post script generates hex and binary file. Binary file required if user uses boot loader to download.

Steps to test or reproduce

Build using 'mbed test --compile'

@0xc0170 0xc0170 requested review from theotherjimmy and c1728p9 May 26, 2017 12:02
@pradeep-gr pradeep-gr changed the title Dual flash and Hex file support added [NCS36510] Dual flash and Hex file support added May 26, 2017
@@ -2801,6 +2801,7 @@
"value": "0xFFFFFFFF"
}
},
"OUTPUT_EXT": "bin",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the default...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to switch support to hex file output, this needs to be changed to "OUTPUT_EXT": "hex". even if the post build script takes the bin and converts it to hex, you still need to make this setting so that the online compiler will know to download the hex to the target and not the bin. this setting does require changes to the post build script.

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tools changes look fine.

@maclobdell
Copy link
Contributor

@studavekar can you check the CI result and re-run if necessary. From the logs, it looks like the failures are unrelated to the code changes made in this PR.

@@ -2846,4 +2847,4 @@
"inherits": ["SARA_NBIOT"],
"extra_labels": ["ublox", "HI2110", "SARA_NBIOT"]
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this unrelated change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not done this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Well then. I'll reapprove this PR.

@theotherjimmy
Copy link
Contributor

We use the pull request titles in the release notes, which are a markdown document. Could you change the title to avoid use of [ and ]? For example "Support dual flash banks on the NCS36510" Would work.

@pradeep-gr pradeep-gr changed the title [NCS36510] Dual flash and Hex file support added Dual flash and Hex file support on NCS36510 Jun 1, 2017
@pradeep-gr
Copy link
Contributor Author

@theotherjimmy Done

@theotherjimmy
Copy link
Contributor

Thanks!

@maclobdell maclobdell changed the title Dual flash and Hex file support on NCS36510 Support dual flash banks and Hex file output on NCS36510 Jun 8, 2017
@maclobdell maclobdell changed the title Support dual flash banks and Hex file output on NCS36510 Dual flash and Hex file support on NCS36510 Jun 8, 2017
@maclobdell
Copy link
Contributor

I checked the build logs and there is no clear failure indicated. I suspect the build test needs to run again.

@sg-
Copy link
Contributor

sg- commented Jun 8, 2017

@pradeep-gr It seems that your editor strips newlines. Can you change the setting and reinstate the newlines? This will cause warning and linting to fail

@pradeep-gr
Copy link
Contributor Author

@sg- Done. Can you try now?

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 26, 2017

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 631

Build failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 26, 2017

@pradeep-gr The Ci failed to build some of the tests for this platform, you can find build log here http://mbedosci.cloudapp.net/results/pr/4397/631

@pradeep-gr
Copy link
Contributor Author

@sg-
Copy link
Contributor

sg- commented Jun 29, 2017

/morph test

@@ -211,5 +238,4 @@ def add_fib_at_start(arginput):
output_hex_file.merge(input_hex_file, overlap='error')

# Write out file(s)
output_hex_file.tofile(file_name_hex, 'hex')
output_hex_file.tofile(file_name_bin, 'bin')
output_hex_file.tofile(file_name_hex, 'hex')
Copy link
Contributor

@maclobdell maclobdell Jun 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pradeep-gr
There is a merge error here that is causing everything to fail. Nothing builds until making a change here. Please add 4 spaces in front of this line to align it with the rest of the function.

    output_hex_file.tofile(file_name_hex, 'hex')

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 702

Build failed!

@pradeep-gr
Copy link
Contributor Author

pradeep-gr commented Jun 30, 2017

@maclobdell @sg- @danclement @danish-iftikhar I am able to build successfully @ commit 9b082ff for GCC_ARM and ARM. But build not started for IAR.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 30, 2017

But build not started for IAR.

What does ti mean "not started" ?

@pradeep-gr
Copy link
Contributor Author

@0xc0170
Find attached IAR build result. It stops at first compile and does not proceed further
IAR_Build_Result.txt

@maclobdell
Copy link
Contributor

@pradeep-gr The behavior when using IAR compiler sounds similar to what happens to me when it can't access our network license server. It just stops on the first file with no error message. Normally, when I'm connected on our network it can find the server and it compiles. Perhaps you are having a similar issue. I just did a quick test and it is working for me.

Please commit the change to the post build script to your branch referenced in this pull request (master branch of https://github.com/pradeep-gr/mbed-os5-onsemi.git). I definitely recommend you run all the tests and confirm it is all working.

@maclobdell
Copy link
Contributor

I ran tests manually using IAR compiler on the branch for the PR (with the change previously mentioned above), plus the master branch. I get 17 errors/fails on this PR branch, but only 1 on master (unrelated issue).
This PR only touches the IAR linker file and post build script + target description for hex file output. The post build script with hex file output are clearly working.

There seems to be a fundamental issue in the IAR linker file that is causing these failures.

The only substantive differences that I see with the new linker file are the following:

  1. the heap size was increased from 0x3000 to 0x4000. But changing it back doesn't help.
  2. the cstack placement is not explicitly set to the end of ram.

previously it was:

place at end of RAM_ALL    { block CSTACK };

now:

place in RAM_region { readwrite, block HEAP, section XHEAP, readonly code section EXECINRAM, overlay MIBOVERLAY, readwrite section MIBENDSECTION, block CSTACK};

@pradeep-gr Can you investigate the map files before and after this change and see if the placement of the heap and stack is the problem?

here are the tests that are failing. I know that many of these are very dependent on RAM allocation.

 NCS36510-IAR 	 Testing read write random blocks                       	 ERROR  
 NCS36510-IAR 	 Testing formatting of master boot record               	 ERROR  
 NCS36510-IAR 	 Testing slicing of a block device                      	 ERROR  
 NCS36510-IAR 	 rtos-rtx5-target_cortex_m-tests-memory-heap_and_stack  	 ERROR  
 NCS36510-IAR 	 Testing calls with 5 args                              	 FAIL   
 NCS36510-IAR 	 tests-mbed_drivers-dev_null                            	 ERROR  
 NCS36510-IAR 	 function init race                                     	 ERROR  
 NCS36510-IAR 	 RTC strftime                                           	 OK     
 NCS36510-IAR 	 STL std::equal                                         	 ERROR  
 NCS36510-IAR 	 tests-mbed_drivers-ticker                              	 FAIL   
 NCS36510-IAR 	 mk time                                                	 ERROR  
 NCS36510-IAR 	 tests-mbedmicro-rtos-mbed-basic                        	 FAIL   
 NCS36510-IAR 	 tests-mbedmicro-rtos-mbed-isr                          	 ERROR  
 NCS36510-IAR 	 tests-mbedmicro-rtos-mbed-mail                         	 ERROR  
 NCS36510-IAR 	 tests-mbedmicro-rtos-mbed-malloc                       	 ERROR  
 NCS36510-IAR 	 Test dual thread lock locked                           	 ERROR  
 NCS36510-IAR 	 tests-mbedmicro-rtos-mbed-queue                        	 ERROR  
 NCS36510-IAR 	 tests-mbedmicro-rtos-mbed-semaphore                    	 ERROR  
 NCS36510-IAR 	 tests-mbedmicro-rtos-mbed-signals                      	 ERROR  
 NCS36510-IAR 	 Testing single thread                                  	 ERROR  
 NCS36510-IAR 	 mbedtls_sha256_self_test                               	 ERROR  

@theotherjimmy
Copy link
Contributor

@pradeep-gr Can you investigate the map files before and after this change and see if the placement of the heap and stack is the problem?

Have you found anything?

@pradeep-gr
Copy link
Contributor Author

CC @danclement @danish-iftikhar

Copy link
Contributor

@maclobdell maclobdell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a summary of a few critical fixes we found. This PR should be good to go once these fixes are made.


/* Handle initialization */
do not initialize { section .noinit };
define region RAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be two critical problems that are causing all the tests to fail. The first is that the stack is not getting placed at the end of RAM. The second issue is that the RAM Vector area is not getting allocated, and the heap is clobbering it.

Creating regions for these sections fixes this. There might be a more elegant solution, but this works.

define region RAM_VECTOR_region   =   mem:[from __ICFEDIT_region_IRAM3_start__  to __ICFEDIT_region_IRAM3_start__ + 0x90 - 1];

define region RAM_region    =   mem:[from __ICFEDIT_region_IRAM3_start__ + 0x90 to __ICFEDIT_region_IRAM3_end__]
                              | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]
                              | mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__ - __ICFEDIT_size_cstack__ ];
                              
define region CSTACK_region =   mem:[from __ICFEDIT_region_IRAM1_end__ - __ICFEDIT_size_cstack__ + 1 to __ICFEDIT_region_IRAM1_end__];                              

define overlay MIBOVERLAY { section MIBSECTION };

define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allocate room for the RAM_VECTORS, define a block similar to CSTACK and HEAP.

define block RAM_VECTORS  with alignment = 8, size = 0x90     { };


place in RAM_ALL { readwrite };
place in RAM_ALL { block HEAP };
place in RAM_region { readwrite, block HEAP, section XHEAP, readonly code section EXECINRAM, overlay MIBOVERLAY, readwrite section MIBENDSECTION, block CSTACK};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the RAM_VECTORS and CSTACK regions...

place at start of RAM_VECTOR_region {block RAM_VECTORS};

place in RAM_region { readwrite, block HEAP, section XHEAP, readonly code section EXECINRAM, overlay MIBOVERLAY, readwrite section MIBENDSECTION};

place at end of CSTACK_region    { block CSTACK };

@danclement
Copy link
Contributor

@maclobdell, does using the IAR 7.80.2 version fix these linker script problems? We had a bad version go out and you have to be at 7.80.2 or newer to avoid it. I sent you a quick phone email on this but didn't have a chance to follow-up until now.

If it's more than this, let me know. Jake is back in the office now so we can pick up our progress on mbed.

@maclobdell
Copy link
Contributor

maclobdell commented Jul 18, 2017

@danclement The linker file used to build mbed OS for this target is within mbed os itself. So the changes I listed are needed. It is not related to the IAR IDE version, however you might also supply the linker file with your support files with IAR too.

@theotherjimmy
Copy link
Contributor

@pradeep-gr Could you respond to @maclobdell's request for changes?

@jacobjohnson-ON
Copy link
Contributor

Generated separate pull request to hasten the requested changes. #4813 should replace this.

binary output file when more than 316K binary is generated. Need updated
daplink bootloader to flash >316K binary file by drag n drop.Refer pull
request generated for flashalgo and daplink repo for more info.IAR lnker
script modified for flash merge-640K and format changed as per IAR
requirement.
@theotherjimmy
Copy link
Contributor

superseded by #4813, so closing this one.

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

Successfully merging this pull request may close these issues.

8 participants