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

IOTSTOR-953: Fix address calculations from SlicingBlockDevice #11797

Merged
merged 11 commits into from Nov 5, 2019
Merged

Conversation

@SeppoTakalo
Copy link
Contributor

SeppoTakalo commented Nov 1, 2019

Description (required)

IOTSTOR-953: Fix address calculations from SlicingBlockDevice

  • Change MBED_ASSERTS() to return valid error code, so that
    checks are not bypassed on release builds.
  • Fix starting address calculations so that "addr" parameter is always
    relative to SlicingDevice and "_start" is only added when calls to
    underlying storage block is made.
  • Bypass BlockDevice:is_valid_*() to underlying block device.
    Slicingblockdevice was just verifying addresses independently, without
    verifying those from underlying block storage.
  • Add module tests for SlicingBlockDevice to verify the problem.
Summary of change (What the change is for and why)

Fix address calculations from SlicingBlockDevice.

This fixed #11781

Documentation (Details of any document updates required)

No documentation update.
No API changes.


Pull request type (required)

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results (required)

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[X] Tests / results supplied as part of this PR

Reviewers (optional)

@VeijoPesonen

Release Notes (required for feature/major PRs)

Summary of changes
Impact of changes
Migration actions required
@SeppoTakalo SeppoTakalo requested a review from VeijoPesonen Nov 1, 2019
@SeppoTakalo

This comment has been minimized.

Copy link
Contributor Author

SeppoTakalo commented Nov 1, 2019

Test results before the last commit:

49: Test command: /Users/septak01/src/mbed-os/BUILD/moduletests-storage-blockdevice-SlicingBlockDevice
49: Test timeout computed to be: 1500
49: Running main() from gmock_main.cc
49: [==========] Running 4 tests from 1 test case.
49: [----------] Global test environment set-up.
49: [----------] 4 tests from SlicingBlockModuleTest
49: [ RUN      ] SlicingBlockModuleTest.constructor
49: [       OK ] SlicingBlockModuleTest.constructor (0 ms)
49: [ RUN      ] SlicingBlockModuleTest.slice_in_middle
49: [       OK ] SlicingBlockModuleTest.slice_in_middle (0 ms)
49: [ RUN      ] SlicingBlockModuleTest.slice_at_the_end
49: [       OK ] SlicingBlockModuleTest.slice_at_the_end (0 ms)
49: [ RUN      ] SlicingBlockModuleTest.over_write
49: mbed assertation failed: is_valid_program(addr + _start, size), file: /Users/septak01/src/mbed-os/features/storage/blockdevice/SlicingBlockDevice.cpp, line 84
49: /Users/septak01/src/mbed-os/UNITTESTS/moduletests/storage/blockdevice/SlicingBlockDevice/moduletest.cpp:142: Failure
49: Expected equality of these values:
49:   slice.program(program, 2*(512), (512))
49:     Which is: 0
49:   BD_ERROR_DEVICE_ERROR
49:     Which is: -4001
49: [  FAILED  ] SlicingBlockModuleTest.over_write (0 ms)
49: [----------] 4 tests from SlicingBlockModuleTest (1 ms total)
49:
49: [----------] Global test environment tear-down
49: [==========] 4 tests from 1 test case ran. (1 ms total)
49: [  PASSED  ] 3 tests.
49: [  FAILED  ] 1 test, listed below:
49: [  FAILED  ] SlicingBlockModuleTest.over_write
49:
49:  1 FAILED TEST
2/2 Test #49: moduletests-storage-blockdevice-SlicingBlockDevice ...***Failed    0.21 sec

The following tests passed:
    features-storage-blockdevice-HeapBlockDevice

50% tests passed, 1 tests failed out of 2

Total Test time (real) =   0.63 sec

The following tests FAILED:
     49 - moduletests-storage-blockdevice-SlicingBlockDevice (Failed)
Errors while running CTest
make: *** [test] Error 8

@SeppoTakalo

This comment has been minimized.

Copy link
Contributor Author

SeppoTakalo commented Nov 1, 2019

After the last commit

49: Test command: /Users/septak01/src/mbed-os/BUILD/moduletests-storage-blockdevice-SlicingBlockDevice
49: Test timeout computed to be: 1500
49: Running main() from gmock_main.cc
49: [==========] Running 4 tests from 1 test case.
49: [----------] Global test environment set-up.
49: [----------] 4 tests from SlicingBlockModuleTest
49: [ RUN      ] SlicingBlockModuleTest.constructor
49: [       OK ] SlicingBlockModuleTest.constructor (0 ms)
49: [ RUN      ] SlicingBlockModuleTest.slice_in_middle
49: [       OK ] SlicingBlockModuleTest.slice_in_middle (0 ms)
49: [ RUN      ] SlicingBlockModuleTest.slice_at_the_end
49: [       OK ] SlicingBlockModuleTest.slice_at_the_end (0 ms)
49: [ RUN      ] SlicingBlockModuleTest.over_write
49: [       OK ] SlicingBlockModuleTest.over_write (0 ms)
49: [----------] 4 tests from SlicingBlockModuleTest (0 ms total)
49:
49: [----------] Global test environment tear-down
49: [==========] 4 tests from 1 test case ran. (1 ms total)
49: [  PASSED  ] 4 tests.
49/50 Test #49: moduletests-storage-blockdevice-SlicingBlockDevice ........   Passed    0.23 sec
@ciarmcom ciarmcom requested review from ARMmbed/mbed-os-maintainers Nov 1, 2019
@ciarmcom

This comment has been minimized.

Copy link
Member

ciarmcom commented Nov 1, 2019

@SeppoTakalo SeppoTakalo force-pushed the IOTSTOR-941 branch 2 times, most recently from 5f437d6 to ab538f5 Nov 1, 2019
@SeppoTakalo SeppoTakalo force-pushed the IOTSTOR-941 branch from ab538f5 to 6f126f6 Nov 4, 2019
@SeppoTakalo SeppoTakalo changed the title IOTSTOR-941: Fix address calculations from SlicingBlockDevice IOTSTOR-953: Fix address calculations from SlicingBlockDevice Nov 4, 2019
@SeppoTakalo

This comment has been minimized.

Copy link
Contributor Author

SeppoTakalo commented Nov 4, 2019

Just realized that I have used wrong Jira ticket number.. This is IOTSTOR-953, not 941.

@SeppoTakalo SeppoTakalo removed the request for review from ARMmbed/mbed-os-hal Nov 4, 2019
Copy link
Contributor

VeijoPesonen left a comment

Looks good to me

@SeppoTakalo SeppoTakalo added needs: CI and removed needs: review labels Nov 4, 2019
Copy link
Member

0xc0170 left a comment

Mainly cosmetic changes requested around licenses

UNITTESTS/target_h/rtos/Semaphore.h Outdated Show resolved Hide resolved
@SeppoTakalo SeppoTakalo force-pushed the IOTSTOR-941 branch from 6f126f6 to a2ffa45 Nov 4, 2019
@@ -874,7 +873,7 @@ int SPIFBlockDevice::_sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_
read_inst = basic_param_table_ptr[SPIF_BASIC_PARAM_TABLE_222_READ_INST_BYTE];
_read_dummy_and_mode_cycles = (basic_param_table_ptr[SPIF_BASIC_PARAM_TABLE_222_READ_INST_BYTE - 1] >> 5)
+ (basic_param_table_ptr[SPIF_BASIC_PARAM_TABLE_222_READ_INST_BYTE - 1] & 0x1F);
debug_if(MBED_CONF_SPIF_DRIVER_DEBUG, "\nDEBUG: Read Bus Mode set to 2-2-2, Instruction: 0x%xh", read_inst);
tr_debug("\nRead Bus Mode set to 2-2-2, Instruction: 0x%xh", read_inst);

This comment has been minimized.

Copy link
@kjbracey-arm

kjbracey-arm Nov 4, 2019

Contributor

Can search-and-replace a bit harder for \n. (Can't immediately see why this was ever at the start of line.)

This comment has been minimized.

Copy link
@SeppoTakalo

SeppoTakalo Nov 4, 2019

Author Contributor

You are commenting a line, that has been commented out from the code..

I should probably drop the whole block of commented out code. I did a search-and-replace but only for active lines.

@mbed-ci

This comment has been minimized.

Copy link

mbed-ci commented Nov 4, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

"--coverage" is synonym to "-fprofile-arcs -ftest-coverage"
https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html

This was causing extra compilation warnings on CLANG.
SeppoTakalo added 10 commits Oct 30, 2019
* Refactor some headers to use relative path from Mbed OS root.
* Refactor some data types to compile on 64bit machines.
* Refactor some debug traces to use mbed_trace.
* Change MBED_ASSERTS() to return valid error code, so that
  checks are not bypassed on release builds.
* Fix starting address calculations so that "addr" parameter is always
  relative to SlicingDevice and "_start" is only added when calls to
  underlying storage block is made.
* Bypass BlockDevice:is_valid_*() to underlying block device.
  Slicingblockdevice was just verifying addresses independently, without
  verifying those from underlying block storage.
This uses HeapBlockDevice for providing the underlying storage block.
Check boundaries that slicingblockdevice do not overlow over to unassigned
blocks.
DeviceKey was using mbedtls_ssl_safer_memcmp() to compare result against
buffer of equal length, but zero content. This comparison makes no sense
as the entropy function is already returning proper error, if it fails.
@0xc0170 0xc0170 self-requested a review Nov 4, 2019
@SeppoTakalo SeppoTakalo force-pushed the IOTSTOR-941 branch from a734d9a to 21987db Nov 4, 2019
@SeppoTakalo

This comment has been minimized.

Copy link
Contributor Author

SeppoTakalo commented Nov 4, 2019

Rebased on top of master, should fix the conflicts.

@0xc0170
0xc0170 approved these changes Nov 4, 2019
@0xc0170 0xc0170 added needs: CI and removed needs: review labels Nov 4, 2019
@0xc0170

This comment has been minimized.

Copy link
Member

0xc0170 commented Nov 4, 2019

Ci restarted

@mbed-ci

This comment has been minimized.

Copy link

mbed-ci commented Nov 4, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

@0xc0170 0xc0170 added ready for merge and removed needs: CI labels Nov 5, 2019
@0xc0170 0xc0170 merged commit 355336c into master Nov 5, 2019
27 checks passed
27 checks passed
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
jenkins-ci/build-ARM Success
Details
jenkins-ci/build-GCC_ARM Success
Details
jenkins-ci/build-IAR Success
Details
jenkins-ci/cloud-client-test Success
Details
jenkins-ci/dynamic-memory-usage RTOS ROM(+0 bytes) RAM(+0 bytes)
Details
jenkins-ci/exporter Success
Details
jenkins-ci/greentea-test Success
Details
jenkins-ci/mbed2-build-ARM Success
Details
jenkins-ci/mbed2-build-GCC_ARM Success
Details
jenkins-ci/mbed2-build-IAR Success
Details
jenkins-ci/unittests Success
Details
travis-ci/astyle Success!
Details
travis-ci/docs Success!
Details
travis-ci/doxy-spellcheck Success!
Details
travis-ci/events Success! Runtime is 8656 cycles.
Details
travis-ci/gitattributestest Success!
Details
travis-ci/include_check Success!
Details
travis-ci/licence_check Success!
Details
travis-ci/littlefs Success! Code size is 8420B.
Details
travis-ci/psa-autogen Success!
Details
travis-ci/tools-py2.7 Success!
Details
travis-ci/tools-py3.5 Success!
Details
travis-ci/tools-py3.6 Success!
Details
travis-ci/tools-py3.7 Success!
Details
@0xc0170 0xc0170 removed the ready for merge label Nov 5, 2019
@SeppoTakalo SeppoTakalo deleted the IOTSTOR-941 branch Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.