Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 17 of 17

Thread: NXP Documentation error?

  1. #1
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9

    NXP Documentation error?

    I am an enthusiastic newcomer to the complexities of modern 32-bit microcontroller technology. What better way to understand this new world than try and follow Paul Stoffregen's Teensy 4.0 Bare-metal Example code. Thank you Paul.

    Eventually everything was becoming clear apart from one cloudy bit: the location of the Boot Image FlexSPI NOR configuration parameters.

    According tp page 216 of NXP's i.MX RT1060 Processor Reference Manual, rev 2/2019: "The ROM expects the 512-byte FlexiSPI NOR configuration parameters block to be present at offset 0x400 in serial NOR flash attached to FLEXSPI_A_SS0_B".

    Now I've read somewhere else that this could should be at a zero offset and indeed this is how Paul does it in his example.

    Am I being rather stupid or is the manual incorrect?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,006
    Yup, it's an error in NXP's documentation.

  3. #3
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9
    Thank thank you Paul. This has been bugging me for quite a few hours!

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,006
    The sad reality is many more minor errors are lurking in those 3437 pages. Some of them confused me for many hours too!

  5. #5
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9
    I'd just like to say to you, Paul, thank you very much for getting me on the way with the complexities of the bare metal coding of your blink app. I couldn't get your cli loader to work on my iMac Big Sur system but that turned out to be down to me not understanding something in the make file. After making some trivial adjustments it just worked. My next venture is to gradually code all this in assembler.

    Is it possible for me, living in UK, to purchase directly from you?

    Once again a big, big thank you for all the work you do, including your philosophy of KISS, otherwise knows as Occam's Razor.

  6. #6
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    168
    It is possible but shipping charges are silly. Not Paul's fault but USPS. Better to buy from Paul's UK distributors.

  7. #7
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9
    Amazon? Surely they screw him into the ground re commission?

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    168
    Quote Originally Posted by Adlibber View Post
    Amazon? Surely they screw him into the ground re commission?
    I said UK distributors. Amazon is not a PJRC distributor.
    UK distributors are:-

    Cool Components, HobbyTronics, Oak Tree LLC, PiHut and Pimoroni.

    They are listed here.

  9. #9
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9
    So PJRC distributors are prepared to sell directly to the retail market?

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    168
    Quote Originally Posted by BriComp View Post
    I said UK distributors. Amazon is not a PJRC distributor.
    UK distributors are:-

    Cool Components, HobbyTronics, Oak Tree LLC, PiHut and Pimoroni.

    They are listed here.
    Oops sorry, I see that Oak Tree LLC is selling through Amazon, but check the prices I think you will see that it is buyer that is being shafted.
    Prices for a T3.2 and LC are:-

    ..............................T3.2....... LC
    Cool Components ...19.99.. 11.39
    HobbyTronics ........ 19.20.. 11.94
    Oak Tree LLC......... 20.29.. 17.59(LC with pins)
    PiHut.................... 18.00.. 11.00 both with header pins (not soldered)
    Pimoroni............... 18.00.. 11.40

    As you can see PiHut has the best prices and supplies free (not soldered) header pins.
    But also bear in mind Oak Tree LLC has free shipping, though this may not be next day. I have used a number of these suppliers and most of them do 24hr Royal mail.

    The best price used to be buying Teensy from OSHPark. But they are unable to do that at the moment. Shipping from them was only $1.
    Last edited by BriComp; 03-06-2021 at 04:17 PM.

  11. #11
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9
    Thanks for all that!

  12. #12
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9
    Just completed a main.S for the blink programme. Blown away by the performance of this little machine (Teensy 4.1). The Assembler version is four times faster than the C code: the uncalibrated delay loop requires 100,000,000 cycles to achieve a delay of approximately half a second. Thats about three clocks a loop!

    But how any beginner could have got to this stage without all the demo code available is beyond me. Understanding the i.MX RT1060 manual is not a logical statement.

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,006
    Quote Originally Posted by Adlibber View Post
    Is it possible for me, living in UK, to purchase directly from you?
    Sadly, PJRC can no longer ship small orders to the UK. Well, not unless you have a VAT ID number.

    The UK recently added a new requirement for VAT collection before shipping. Large companies like Amazon are doing it. Small companies like PJRC, not so much.

    Your best option is definitely to buy from one of the UK distributors.

  14. #14
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,769
    Quote Originally Posted by Adlibber View Post
    Just completed a main.S for the blink programme. Blown away by the performance of this little machine (Teensy 4.1). The Assembler version is four times faster than the C code: the uncalibrated delay loop requires 100,000,000 cycles to achieve a delay of approximately half a second. Thats about three clocks a loop!

    But how any beginner could have got to this stage without all the demo code available is beyond me. Understanding the i.MX RT1060 manual is not a logical statement.
    Indeed the T_4.1 is fast - and PJRC support code makes avoiding the RefManual generally easy - and the resulting code is tested for correctness and presented for use.

    Would be cool to see that on a thread. ASM.s code used versus c code for blink - not sure what it entailed?

    This C sketch toggles LED pin 100M times in one third of a second just over 2.0 cycles per loop and second loop watches for half second of cycles to pass and only completes 60M cycles - so 10 cycles per loop with ref of the CYCCNT taking 3 cycles IIRC:
    Code:
    void setup() {
    	while (!Serial && millis() < 4000 );
    	Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
    	pinMode( 13, OUTPUT );
    
    	uint32_t tClk = ARM_DWT_CYCCNT;
    	int ii;
    	for ( ii = 0; ii < 100*1000*1000; ii++ ) digitalToggleFast(13);
    	tClk = ARM_DWT_CYCCNT - tClk;
    	Serial.printf("[100M] %lu loops LED toggle in cycles %lu\n", ii, tClk);
    	Serial.printf("[100M] %lu loops LED toggle in Sec %f\n", ii, 1.0*tClk/F_CPU_ACTUAL);
    
    	tClk = ARM_DWT_CYCCNT;
    	for ( ii = 0; ii < 100*1000*1000; ii++ ) if ( ARM_DWT_CYCCNT-tClk > F_CPU_ACTUAL/2) break;
    	tClk = ARM_DWT_CYCCNT - tClk;
    	Serial.printf("%lu loops test to half Sec in cycles %lu\n", ii, tClk);
    	Serial.printf("%lu loops test to half Sec %f\n", ii, 1.0*tClk/F_CPU_ACTUAL);
    }
    void loop() {}
    Output:
    Code:
    T:\tCode\FORUM\MinWait\MinWait.ino Mar  8 2021 17:15:59
    T:\tCode\FORUM\MinWait\MinWait.ino Mar  8 2021 17:27:39
    [100M] 100000000 loops LED toggle in cycles 200010460
    [100M] 100000000 loops LED toggle in Sec 0.333351
    59996864 loops test to half Sec in cycles 300000012
    59996864 loops test to half Sec 0.500000

  15. #15
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9
    Happy to provide the assembler version of the main.c file. I am working on an iMac Big Sur and from the command line, i.e. not using Arduino.

    Are you familiar with Paul's Bare Metal Blink code? I'm using the same folder structure and have kept his boot.c and startup.c as provided. I lost a few hours today with weird behaviour with the find command in the Makefile but found a way to deal with it!

    If you can tell me how I can upload the (small) main.S source - I can't figure how to do it!

  16. #16
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,769
    Quote Originally Posted by Adlibber View Post
    Happy to provide the assembler version of the main.c file. I am working on an iMac Big Sur and from the command line, i.e. not using Arduino.

    Are you familiar with Paul's Bare Metal Blink code? I'm using the same folder structure and have kept his boot.c and startup.c as provided. I lost a few hours today with weird behaviour with the find command in the Makefile but found a way to deal with it!

    If you can tell me how I can upload the (small) main.S source - I can't figure how to do it!
    On post lower right - 'Go Advanced' - allows file upload in that mode with item on the toolbar. Not sure if it respects .s as an extension - would need to make it .txt or put in a zip - but shouldn't be that large?

  17. #17
    Junior Member
    Join Date
    Mar 2021
    Location
    UK Hampshire
    Posts
    9

    main.S

    Here goes!
    main.txt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •