[Tool] Automatically transfer build files from MBED Compiler

08 Feb 2017

Hi all,

I've made a script for Linux/MacOS devices which automatically transfers bin files downloaded from MBED compiler to your MBED device. I've found it convenient as it saves time specifying the download folder and then confirming an overwrite following each compilation.

Currently, it only works if your MBED device is located at /media/MBED however, should people find this tool convenient, I'd be happy to add argument functionality so users can specify the MBED devices location manually.

Source: https://github.com/andy-richardson/mbed-watcher

Best wishes!

08 Feb 2017

As a Windows user, I use this .bat file for the same purpose. On this PC, the mbed always lands as f:, so about the only thing to change. I launch it from my "downloads" folder. I used to redirect the browser downloads straight to the mbed, but didn't like that as well.

After I launch this, I just tuck it into a corner of the screen. Not every version of Windows has "Timeout". I used to have a one-line perl script do that.

@echo off
:Start
if not exist *.bin goto wait

move /y *.bin f:\    & time /T

:wait
Timeout /T 10
goto Start
08 Mar 2017

Those are very useful tools. Thank you for sharing.

09 Mar 2017

Hi,

Like David i use batch code to search Mbed disk, clean it from old .bin files, call Makefile and automatically transfer the new build file if source code successful compilation.

I hope you found it useful.

scriptMbed.bat

@echo off
:: nom du script Batch : scriptMbed.cmd
:: but du script Batch : compiler un code pour le Mbed LPC1768 et copier le binaire sur le Mbed
:: script Batch écrit par : YSI
@title scriptMbed
:: on vérifi l'emplacement de scriptMbed en regardant si on trouve le Makefile
if EXIST Makefile (
    :: suppression s'il existe de tout le dossier .build et de ses sous dossiers sans demande de confirmation
    if EXIST .build rmdir .build /s /q
    :: appel du Makefile pour creer le dossier .build et si la compilation est un succès les fichiers qui le compose
    make -s
    :: si un fichier .bin existe dans le dossier .build on entre dans le for
    for %%f in (.build\*.bin) do (
        :: on prévient l'utilisateur
        echo -------------------------------------------------------------------------
        echo Successful build from '%%f'
        echo -------------------------------------------------------------------------
        :: on boucle sur les lettres de l'alphabet pour trouver le volume MBED
        for %%v in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
            :: on detecte le Mbed
            vol %%v: 1>nul 2>&1 && if NOT ERRORLEVEL 1 if EXIST %%v:\nul if NOT %%v:==%systemDrive% if NOT %%v:==%homedrive% if EXIST %%v:\mbed.htm (
                :: on prévient l'utilisateur
                echo -------------------------------------------------------------------------
                echo Mbed found '%%v:'
                echo -------------------------------------------------------------------------
                :: on vide le Mbed de ses fichiers .bin
                del %%v:\*.bin
                :: on prévient l'utilisateur
                echo -------------------------------------------------------------------------
                echo Mbed '%%v:' cleanned
                echo -------------------------------------------------------------------------
                :: on copie le fichier .bin issu de la compilation sur le Mbed
                copy %%f %%v:
                :: on affiche des infos sur le contenu du Mbed
                dir %%v:\*.bin
                :: on écrit dans un fichier de logs des informations sur le moment de la copie
                echo %date% %userdomain% %username% %time% %%f >> CopyLogs.lgs
                :: on prévient l'utilisateur
                echo -------------------------------------------------------------------------
                echo Successful copy from '%%f' to 'Mbed %%v:'
                echo -------------------------------------------------------------------------
                echo.
                :: on va à la fin du programme
                goto end
            )
        )
        :: on prévient l'utilisateur
        echo -------------------------------------------------------------------------
        echo Failed copy from '%%f' to 'Mbed unknown'
        echo -------------------------------------------------------------------------
        echo.
    )
) else (
    :: on prévient l'utilisateur
    echo -------------------------------------------------------------------------
    echo Failed build and copy, 'Makefile not found' 
    echo -------------------------------------------------------------------------
    echo.
)
:: label de fin de progamme
:end