{"id":3186,"date":"2022-08-02T16:27:04","date_gmt":"2022-08-02T14:27:04","guid":{"rendered":"https:\/\/www.kurokesu.com\/main\/?p=3186"},"modified":"2022-08-02T19:27:53","modified_gmt":"2022-08-02T17:27:53","slug":"ethernet-camera-module-build-log-5-automated-flashing","status":"publish","type":"post","link":"https:\/\/www.kurokesu.com\/main\/2022\/08\/02\/ethernet-camera-module-build-log-5-automated-flashing\/","title":{"rendered":"Ethernet camera module build log #5 \u2013 Automated flashing"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Developing firmware for an embedded device requires a lot of testing. Processors capable of running full-featured operating systems are much more complicated than smaller controllers (but obviously also are more flexible). Some tests can be done on the host machine, but in most cases (especially related to specific peripherals), it is best to run tests on actual hardware.<br>Let&#8217;s run quickly through some of the flashing methods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NAND\/NOR flash programming<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">External or internal flash chip programming is the preferred device program method. Some processors and microcontrollers offer security features to protect firmware so it would be locked away from access from unauthorized access. It is possible to order flash chips flashed with a bootloader or complete firmware image for large-scale production.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bootloader<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If a processor or microcontroller has a hardware bootloader, this is also an excellent method to upload the firmware. In some cases, the hardware bootloader is not enough, and software bootloaders are used, for example, u-boot. It&#8217;s not particularly complicated to configure u-boot to load a portion of the firmware from the TFTP server and automate the programming\/testing procedure. However, special software or computer setup is needed in most cases. For example, in some other cases device connected to a computer via a USB port can register as a virtual disk, and it is enough to drag and drop new firmware via file manager.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SD card \/ USB flash disk swap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Physical swap SD card \/ USB disk is the safest and easiest way for initial flash transfer from the development computer to the device being tested. Also, it requires minimal knowledge from a customer. The main disadvantage &#8211; someone has to swap an SD card or USB disk and reset the board by hand.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Automated SD card swapper<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Initially, I contemplated a robot carrying a physical SD card like in the movie&nbsp;<a href=\"https:\/\/www.imdb.com\/title\/tt0113243\/\" target=\"_blank\" rel=\"noreferrer noopener\">Hackers<\/a>, but there should be an easier way&#8230; and it turns out there is!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SDWire<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Tizen was more innovative than the movie! They designed SD wapper with no moving parts and called it&nbsp;<a href=\"https:\/\/wiki.tizen.org\/SDWire\" target=\"_blank\" rel=\"noreferrer noopener\">SDWire<\/a>. Even better &#8211; this is an open source project, but can be purchased ready build.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"682\" src=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r-1024x682.jpg\" alt=\"\" class=\"wp-image-3199\" srcset=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r-1024x682.jpg 1024w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r-300x200.jpg 300w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r-768x512.jpg 768w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r-1536x1024.jpg 1536w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r.jpg 2000w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s a micro SD card with a USB port. Once it is plugged into DUT (Device Under Test) SDWire role can be changed from the host computer.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Mode1 &#8211; Virtual disk over USB port (host computer has full access to the SD card)<\/li><li>Mode2 &#8211; SD card (DUT has full access)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The host computer also has access to secondary control interface over the same USB port. Running it on the VirtualBox machine was straightforward. Just forward communication of&nbsp;<strong>sd-wire<\/strong>&nbsp;and&nbsp;<strong>Generic Ultra Fast Media Reader<\/strong>&nbsp;USB devices, and it should work.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"783\" height=\"423\" src=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/image-1.png\" alt=\"\" class=\"wp-image-3194\" srcset=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/image-1.png 783w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/image-1-300x162.png 300w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/image-1-768x415.png 768w\" sizes=\"auto, (max-width: 783px) 100vw, 783px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Further installation is as easy as installing some dependencies and compiling software.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install cmake libftdi1-dev libpopt-dev<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Compile control software<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/git.tizen.org\/cgit\/tools\/testlab\/sd-mux\ncd sd-mux\ncmake -S . -B build\ncmake --build build\nsudo cmake --install build<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Command will switch SDWire into Mode1 (connect SD card to the host computer)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sd-mux-ctrl --device-id=0 --ts<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The second command will switch SDWire into Mode2 (connect SD card to the Device Under Test)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sd-mux-ctrl --device-id=0 --dut<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">One thing I am missing from SDWire is DUT power control. Not complaining, though. This super simple project can be implemented on any microcontroller and ordinary relay in no time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Developing firmware for an embedded device requires a lot of testing. Processors capable of running full-featured operating systems are much more complicated than smaller controllers (but obviously also are more flexible). Some tests can be done on the host machine, but in most cases (especially related to specific peripherals), it is best to run tests [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3199,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[157],"tags":[459,470,62,468,15,467],"class_list":["post-3186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","tag-allwinner","tag-buildroot","tag-camera","tag-flash","tag-linux","tag-sd-card"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2022\/08\/IMG_7202_r.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6VSmB-Po","_links":{"self":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts\/3186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/comments?post=3186"}],"version-history":[{"count":9,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts\/3186\/revisions"}],"predecessor-version":[{"id":3204,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts\/3186\/revisions\/3204"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/media\/3199"}],"wp:attachment":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/media?parent=3186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/categories?post=3186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/tags?post=3186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}