Uncategorized

buster image flashing mistake record

tlfong01

tlfong01
2698
Feb 6, 22:23
I am now do the top down design of the using the big library as a blueprint. The startup sections are in the top part of the following file: penzu.com/p/772fa292. Next step is reading the datasheet a couple of times and modify the template functions for nrf24.
First thing first is to read the block diagram of the nrf24 module.
user image
Then a brief description.
user image
Then a state diagram.
user image
The state diagram show TX mode and Rx mode. So I think I need to get a rough picture of what is TX and Rx modes.
user image
Then we need to check out the register map to see which registers to config, which to give commands etc. I think I should start with the config register, never mind other not so important registers.
user image
Then we need to read the command set to know how to load a message, how to send, how to receive etc etc.
user image
It is indeed very messy. Bed time. So I will call it a day. See you tomorrow.
StevenCellist

StevenCellist
11
Feb 6, 23:42
Whoa man, indeed this is a mess
I am so grateful for everything you are doing!!
I lost it when you started talking about the block diagram etc haha
I don’t know how you’re doing all this but thank you so much in advance! 🙂
10 hours later…
tlfong01

tlfong01
2698
Feb 7, 9:58
Yes, even the nRF24 block diagram is hard to understand. But at least you must be not too lazy enough not to search the datasheet for meanings of terms like “PA”, “LNA”, GFSK” and so on, otherwise you will never catch up. Anyway, for now, you can just as I suggested earlier, sit back and watch how I am building a minimal nRF24 driver and library, … No hurry though, take your time. Cheers.
2 hours later…
tlfong01

tlfong01
2698
Feb 7, 11:33
Now I am looking at the init method of the nRF24 library (full listing at nRF Learning Notes V0.6) penzu.com/p/303513ed The init method is basically doing two things: (1) Init SPI and GPIO assignment, (2) Configuration using 9 statements. So now I need to check out what those 9 statements are doing, and which registers, beside the Config register, need to be written:
user image
tlfong01

tlfong01
2698
Feb 7, 11:47
Now I move on reading the “begin” method of the nrf24 class. I think the transmit.py is doing something like below: (1) create/instantiate an object of the nrf24 class. This newly created object is called “radio”. Then “radio.init” and “radio.begin” methods are called to do the initiation/setup job. Now I need to study the “begin” method and see how to do it using the functions (yes, no longer objects, all functions now) to do the corresponding “init” and “begin” tasks.
3 hours later…
tlfong01

tlfong01
2698
Feb 7, 15:06
Now I read the nRF24 begin method and found it not that complicated, calling 6 functions and writing 3 registers. I guess the minimal driver must at least entertain these 3 registers. So I go check out these three registers.
user image
The three register to write are : “setup”, “dynamic playload”, and “current status”. I was confused why there is a “setup” register and not using the “config” register.
StevenCellist
StevenCellist
Feb 7, 15:59
Alright I understand this
tlfong01

tlfong01
2698
Feb 7, 16:57
Good. Now I quickly read the datasheet again, and picked a couple more registers to do the preliminary testing. I am thinking of using these basic registers to do config, command, and status control. I now appreciate the use of the state diagram, without that you might get lost during transitions from Tx mode ot Rx mode etc. The config register help to set up maximum power, the status register can check output. I am hoping to use the scope to check the output waveform.
user image
user image
user image
17 hours later…
tlfong01

tlfong01
2698
Sat 10:21
I am casually googling around to see what other experts talking about nRF24. I noticed one expert saying that “… it is not easy to tune the signal strength …”. I was wondering that should I set the transmitting power to maximum to ensure max reception? Reference: (1) [Cheap COTS (Commercial Off The Self) transceivers that work with Raspberry Pi? – Asked 2015 Viewed 924 times]:
raspberrypi.stackexchange.com/….
I also noticed that the nRF24 module is a 5+ year old product, and so should be mature and reliable, worth spending time on it (though the library is not perfect, and no longer supported by the original developer, but then it is more challenging than using a BettyFruit library and everything goes smoothly, spoiling you too lazy to learn.
7 hours later…
tlfong01

tlfong01
2698
Sat 17:26
I am testing two nrf24 modules at the same time, using the following /boot/config.txt, with 2 SPI buses and 5 Chip Selects. The following record is for your reference, in case you wish to use later. Cheers.
user image
3 hours later…
tlfong01

tlfong01
2698
Sat 20:00
Now I am testing the SPI two and three bytes loopback functions, which are used later to read and write nRF24 registers. You can search this forum using keywords “SPI”, “loopback” for newbie friendly Rpi3+ stretch test programs for both SPI1 and SPI2. I am using Rpi4B buster version now. I am using low SPI frequency of 100kHz, so I can use long wiring. Later I might increase to 1MHz. The is the waveform capture: imgur.com/gallery/aFVfLg2.
tlfong01

tlfong01
2698
Sat 20:19
user image
4 hours later…
StevenCellist
StevenCellist
Sun 0:14
Of what I know, the signal strength shouldn’t be set to max when the radios are close to each other. The signal can be too strong, and minimum power should be able to work perfectly fine
9 hours later…
tlfong01

tlfong01
2698
Sun 9:10
Ah, I never thought about that. I wrongly thought that the nRF24 if working as a receiver, is like my FM radio receiver, the strong the signal the better, because I can always use the volume knob to adjust any too strong signals received. Anyway, I need to pause a bit and google harder, to make sure I am not thinking other amateurish thoughts. On second thought, perhaps I can add a manual signal and volume adjust option to my python program. Cheers.
1 hour later…
tlfong01

tlfong01
2698
Sun 10:20
@StevenCellist About your comment: “… I did get a warning on my B+ model actually about one of the pins already being in use, but it continued anyway …”, I vaguely remember that one of the reasons that you might get this kind of warning messages is that you are trying to set a GPIO pin to input or output mode, but that GPIO pin has already been setup earlier. So it is just a warning, nothing important. There seems to be a flag to disable this kind of warning, but again not that important.
By the way, I found that I need to use a GPIO pin to control the CE, module enable/disable pin for certain kind of Tx operation. And we may need another GPIO pin set to input mode to entertain the Interrupt status output of the nRF24 module. So now I need two pins x 4 for 4 modules of my project. I think I need to write a simple python GPIO only module to handle these 8 CE/Interrupt pins.
7 hours later…
tlfong01

tlfong01
2698
Sun 17:19
Now I am going to assign GPIO pins for my 4 nRF24 modules. I looked at the pinout map and found there are not too many pins to go around, because the 6 SPI buses occupy quite a number of pins. So my first thought is to just use SPI1, SPI1, and forget SPI3 to SPI6. So I assign 1 GPIO pin for each module’s CE, and one more pin in pull down configuration, to share among all 4 modules.
The pin map is rather messy, even I am only looking at the SPI pins. I still need to entertain the 5 I2C buses and at least one UART/serial TxD, RxD. Indeed I cannot make end make and must make a big engineering trade off in using the pins.
user image
4 hours later…
tlfong01

tlfong01
2698
Sun 21:28
I always wrongly thought that SPI0 has CE0, CE1, but SPI1 has only CE2, but no CE1. Now I found made a mistake, there is actually CE0 for SPI1, but no CE0. I don’t know why. Anyway, now I extracting the following pins/wires: SPI0 CE0, CE1 and SPI1 CE1, CE2. Together with Ground wire, each of SPI0, SPI1 has 6 wires, as show below.
user image
Please let me know if you guess why there is no CE0 for SPI1. This seems inconsistent.
tlfong01

tlfong01
2698
Sun 22:12
user image
15 hours later…
tlfong01

tlfong01
2698
Mon 12:44
buster has just release another update with a faster Thonny. So I am taking a break here to do the updating. See you later. By the way, three questions: (1) Do you know what is TDD? (2) have you any experience in using python list and dictionary data structure in programming? and (3) Do you prefer OO than FP (Functional Programming)?
user image
tlfong01

tlfong01
2698
Mon 12:57
I hope you can also update your buster in time, so we can later compare our programs using the same versions of SpiDev, python, and Thonny. (1) Raspbian Buster Gets New Features in Big Update By Ash Puckett 7 hours ago New changes and lots of features!
tomshardware.com/news/…

(2) New Linux 5.5 – Supports Raspberry Pi 4! By yida 9 hours ago
seeedstudio.com/blog/2020/02/…

5 hours later…
StevenCellist

StevenCellist
11
Mon 17:28
@tlfong01 Isn’t pin 12 the CE0 for SPI1?
I didn’t know what TDD was but I looked it up and I see what it means
I do have experience with python lists, my exam two weeks ago made quite a bit of use of those
And I really prefer OOP over FP, so I can make changes much easier to my specific codes
I’ll be updating my Pis to the new version soon
On a side note: there’s really no need for me to entertain 6 radio’s.. lol. For my current plans I only need one per Pi. I won’t mind a code that’s ready to add a second but six would totally overkill for me 🙂
tlfong01

tlfong01
2698
@ StevenCellist: “Isn’t pin 12 the CE0 for SPI1?”, Oh my goodness, Thank you very much for pointing out my “Blind Spot”. I actually went through the Tom’s Hardware pin table three times, before giving up, with a conclusion that (1) Tom’s Hardware pinout table is buggy, (2) buster’s ls /dev/spi* is buggy, (3) me only cannot make any mistakes. So last night slept well. But to night I won’t sleep well, … 😦
StevenCellist

StevenCellist
11
Ahaha don’t worry bro! You have been doing some awesome work already and you don’t wanna know what kind of mistakes I have been making already.. like the time.sleep(100)
You should rest well
tlfong01

tlfong01
2698
Mon 17:49
I agree there is no need to have 6 RF transceivers. I only need one on either side. It is only for “swap/pairing/cross checking/testing” that I need two each side. But then later when I move the slave to my rooftop garden, I may need two on the rooftop, one standby in case of another break down.
I usually test four devices to make sure that even two devices are OK, I must be very sure that my list of two devices can 100% sure scale up to 4, 8, … 64 radios. Ah, I forgot to comment on your comments that why I bought 6.
StevenCellist
StevenCellist
Ahh okay, I see!
tlfong01

tlfong01
2698
I almost could not sleep well to night, because just now I made another careless but very severe mistake when trying flashing the new buster image. Let me show you my installation record, and then, … Ah dinner time, see you later.
user image
StevenCellist

StevenCellist
11
I can’t read Chinese but that ‘s an error I see! Oops!
It should be possible to do it via ‘sudo apt-get update’ and upgrade, right? Else I’ll have to wait another day
Have a nice meal!
tlfong01

tlfong01
Mon 18:06
Ah, you seem to be an impatient guy. OK, here is a tip: I tried to boot but I got the infamous twinkle, twinkle, twinkle, twinkle little green star! 🙂
StevenCellist
StevenCellist
Ohhh that isn’t gonna boot
Well I’m going to take a shower so I’ll be back too
3 hours later…
tlfong01

tlfong01
2698
Mon 21:10
Another tip: FAQ V0.1 of Using Win32Image Manager v1.0 to flash buster release 2020feb05 image on a 16GB SD Card – tlfong01 2020feb10hkt2107

Q1. If Win32Image Manager V1.0 gives error message when trying to flash a buster image, what should I do?
A1. Use SD Formatter V4.0 to “Overwrite mode” format the SD card (yes, “Quick format mode” won’t do), then the SD card will now be flashable.

Q2. If after SD Formatter V4.0 has “overwrite formatted” the previously Win32ImageManager unflashable SD card, it is now indeed flashable, but

(see full text)

How come so confusing: one drive after SD Formatter V4.0 has “overwrite” formatted, becomes two drives? what is going on?
2 hours later…
StevenCellist
StevenCellist
Mon 23:31
Is this a question to me? If so, I don’t understand your question
I don’t use Win32Image Manager but balenaEtcher
10 hours later…
tlfong01

tlfong01
Tue 9:35
Ah sorry, I though you might have used WinImgv1.0 before. Anyway, let try balenaEtcher and see if I still have the same or similar problem.
2 hours later…
tlfong01

tlfong01
2698
Tue 11:14
Yet one more tip: Guess what careless, but with severe consequence, mistake I made yesterday?
user image
5 hours later…
StevenCellist
StevenCellist
Tue 16:15
I don’t know?
tlfong01

tlfong01
2698
Tue 16:43
@StevenCellist What did you mean by “I dont’ know”. Perhaps you misunderstood my puzzle. There is nothing important or urgent. I just jokingly wanted to test if your eyes are sharp enough to correctly guess what did I do wrong when using WinImageManager v.10 and SD Formatter 4.0 to flash the buster image but got the green LED blinking error. As you might know already, the green LED blinking 4 times is a common newbie sorrow and from time to time I hear newbies swearing the whole galaxy.
The screen capture shows how a ninja image flasher like me might still made a careless mistake resulting a severe damage. But if you don’t know how to use WinImageV1 and SDformatterV4 you won’t understand my question and therefore not appreciate the dangerous trap to the newbies. Perhaps one day you learned how to use WinImage and SDformatter, then I will explain.
Anyway, today I thought I might try BalenaEtchere again, and see if it is good for newbies and ninja alike, particularly to avoid making careless mistakes, some of which might create winkling green stars, therefore saving the galaxy from being over cursed. But then I spent about an hours, flashing a couple of 16GB SD cards and found Balena has disappointed me, and should also disappoint other ninja flasher.
For newbies who don’t know the meaning of FAT64, boot sectors etc, I think Balena is appropriate for them. Rpi4B and buster is changing the boot architecture, so I think it is waste of time digging this subject further. So I stopped here, and moving back to the nrF24 minimal driver project.
tlfong01

tlfong01
2698
Tue 17:05
By the way, about your comment “And I really prefer OOP over FP, so I can make changes much easier to my specific codes”. This is interesting, and I might discuss this later, perhaps when we finished our project. My casual goal is to finally developed two versions of the same nRF24 driver, the OO version to be surpervised by you, and me FP. Actually my preference is DP, “Declarative Programming”.
Have you heard about DP, and Proglog? I vaguely remember that not to many years ago Imperial College used Prolog as the first programming language for their CS freshman, and MIT and Harvard use Lisp (latter Scheme) and Haskell for their CS new comers (not EE guys).
Anyway, I am using DP, in the crude form of python dictionaries, and I am interested to know if you can also use dictionaries in your OO version of nRF24 minimal driver (It should be easier for you to convert my finished FP version of nRF24 to OO. Ah, I have been talking too much, it is dinner time. See you tomorrow, cheers. PS – I am just thinking aloud, my apologies for all the typos.
And in case you have not known already, the GPIO.Zero developer guy is programming in the declarative program style. You might like to check him out in your free time. Again nothing important or urgent. Cheers.
StevenCellist

StevenCellist
11
Tue 17:38
I’d have to dive into all that terminology etc to understand all those different types. I only learned two weeks ago the meaning of OOP and FP from my friend who studies Informatica (if you know what that is) and he’s been telling me some bits about it
I might ask him later about DP or I’ll Google a bit around
5 hours later…
tlfong01

tlfong01
2698
Tue 22:23
Well, take it easy and go slowly. For now, you just need to understand stuff shallow, just a rough picture of the functions I am writing. As I suggested earlier, you might, as we go along, convert my FP functions one by one, to your OO methods.

And as the saying goes, eat the big elephant bite by bite – First bite is SPI setup, Second, nRF24 initiatization, third, nrF24 configuration, …

This way you taste each bite slowly, understand and enjoy, …

I am a huge fan of the mad electrical engineer Oliver Heaviside, and agree very much what he is saying: “Shall I refuse my dinner because…

(see full text)

There you are, the first bite – SPI:
user image
user image
I am calling it a day. See you tomorrow.
3 days later…
tlfong01

tlfong01
2698
17:08
I found buster release 2020feb05 very good, there are still some teething problems. I tidied up my hardware and software setup, and made a record for future reference. I uploaded a copy here, in case you are interested to see what I am doing.
user image
tlfong01

tlfong01
2698
17:42
Let let me go back to the question about image flashing. Since you are not using SDFormatter,you won’t appreciate the big mistake I careless made. It is a bit subtle to explain: (1) If you flash a Rpi image to a SD card, the SD card will be partitioned to two drives, ie, one SD card has two drives. Now if you are not careful, you might miscount the drive number, and like poor me, wrongly formatted the wrong drive which is a 500GB SSD!
Luckily I have been incrementally backing up files, therefore nothing valuable is lost. Anyway, so when I used the not flashed SD card to boot, I get the green LED blinking four times error message. I guess many newbies make the same mistake and swear half of the Galaxy that they did not do anything wrong. The flashing trap is illustrated below.
user image
I forgot to update something in the above image, but now it is old to update. So now I upload the updated one, with the mistakes highlighted, my apologies.
user image

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.