Skip to content

RTL8195AM - refactor bootloader and fota support #5531

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

Merged
merged 2 commits into from
Nov 30, 2017

Conversation

tung7970
Copy link
Contributor

Description

Refactor bootloader and fota support.

  1. redefine OTA flash regions

OTA regions are moved to 0x040000 and 0x120000 to make room for mbed credentials and settings.

  1. redefine bootloader headers

Headers are redefined for better integration with mbed cloud FOTA services.

Status

READY

Migrations

NONE

Related PRs

NONE

Todos

NONE

Deploy notes

NONE

Steps to test or reproduce

NONE

#define OTA_TAG_OFS 0x0
#define OTA_VER_OFS 0x4
#define OTA_EPOCH_OFS 0x8
#define OTA_SIZE_OFS 0xf
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the size offset be 0x10?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap. It should be 0x10. Thanks.

@marcuschangarm
Copy link
Contributor

@tung7970

I'm unable to boot up. This is the error I'm getting:

Image1 Validate OK, Going jump to Image1
BOOT from Flash:YES
SPI calibration
Find the avaiable window
SDR Controller Init:0; Delay start:0; Delay end:63
Test 0: No match addr 0xc9d38 => 0xf != 0xc
Test 0: No match addr 0x1f7c10 => 0x5 != 0xe
ram2: crc32 4d32fd02 <==> f3fc3585
ram2: crc32 9be76dba <==> aceefcf9
Unable to boot image 2

@tung7970 tung7970 force-pushed the feature-fota branch 2 times, most recently from e36f9a3 to d1d31c7 Compare November 21, 2017 03:41
@tung7970
Copy link
Contributor Author

@marcuschangarm Hi, updated bootloader. Please give it a try. Thanks.

@marcuschangarm
Copy link
Contributor

@tung7970 It works now! We are back in business!

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 22, 2017

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 22, 2017

Build : FAILURE

Build number : 571
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5531/

@kegilbert
Copy link
Contributor

kegilbert commented Nov 22, 2017

When running locally looks like a string is being passed in the number argument to format_number causing the

line = format(number, '0%dx' % (width))
ValueError: Unknown format code 'x' for object of type 'str' 

error.

Specifically the RAM2_HEADER tag and ver fields look like junk when running on the event_flags test for example.

@marcuschangarm

@marcuschangarm
Copy link
Contributor

I don't understand why not all of the compilations are failing. In the trace output, most of the binaries are created correctly.

What command are you using? When I build locally it works:

mbed test --compile -m REALTEK_RTL8195AM -t GCC_ARM

@kegilbert
Copy link
Contributor

Running the same command I can reproduce the error on the CI test node and on a local Linux machine both running Python 2.7.12.

That's really strange, I'm honestly not sure why only certain builds cause it. It doesn't seem to happen to the same binaries each time.

@marcuschangarm
Copy link
Contributor

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 24, 2017

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 24, 2017

Build : SUCCESS

Build number : 592
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5531/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci
Copy link

mbed-ci commented Nov 24, 2017

@mbed-ci
Copy link

mbed-ci commented Nov 24, 2017

@marcuschangarm
Copy link
Contributor

Can we get this in before the freeze, please? 😄

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2017

Can we get this in before the freeze, please? 😄

Waiting for review from @theotherjimmy (tools changes)

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

The print might be removed, the rest LGTM

return 0;
}

printf("OTA: read addr=0x%lx\r\n", addr);
return flash_ext_stream_read(&flash_obj, addr, len, data);
printf("OTA: read addr=0x%lx\r\n", start);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this debug print? Should not print always?

Preparing for bootloader redesign.

Signed-off-by: Tony Wu <[email protected]>
1. move ota region 1 from 0x00b000 to 0x040000
2. move ota region 2 from 0x0c0000 to 0x120000
3. refactor bootloader header as follows:

   uint32_t tag;
   uint32_t ver;
   uint64_t timestamp;
   uint32_t size;
   uint8_t hash[32];
   uint8_t campaign[16];
   uint32_t crc32;

   where,
   a. hash is the sha256 checksum of the payload.
   b. crc32 is the crc32 checksum of headers from tag to campaign.

4. Call NVIC_SystemReset for soft reset.

Signed-off-by: Tony Wu <[email protected]>
@tung7970
Copy link
Contributor Author

@0xc0170 Done.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2017

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 28, 2017

Build : SUCCESS

Build number : 614
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5531/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci
Copy link

mbed-ci commented Nov 28, 2017

@mbed-ci
Copy link

mbed-ci commented Nov 28, 2017

@theotherjimmy
Copy link
Contributor

Before I approve this, @tung7970 Are the tools changes backwards compatible? That is, If I were to use the tools directory to compile, say, Mbed OS 5.5.7, would it work?

@tung7970
Copy link
Contributor Author

@theotherjimmy Yes. This commit is atomic, as long as python script and bootloader bin are used together.

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.

Thanks. Be aware this this will upgrade all website builds to the new bootloader when the tools on the website are upgraded. This includes older releases of Mbed OS.

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

Successfully merging this pull request may close these issues.

6 participants