@@ -2685,6 +2685,49 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
26852685 program .set_defaults (target = target , toolchain = tchain )
26862686
26872687
2688+ # device management commands
2689+ @subcommand ('device-management' ,
2690+ dict (name = ['-t' , '--toolchain' ], help = 'Toolchain used for mbed compile' ),
2691+ dict (name = ['-m' , '--target' ], help = 'Target used for compile for target MCU. Example: K64F, NUCLEO_F401RE, NRF51822...' ),
2692+ dict (name = ['--profile' ], help = "" ),
2693+ dict (name = '--build' , help = 'Build directory. Default: build/' ),
2694+ help = 'device management supcommand' ,
2695+ hidden_aliases = ['dev-mgmt' , 'dm' ],
2696+ description = ("Manage Device with Palion" ))
2697+ def dev_mgmt (toolchain = None , target = None , source = False , profile = False , build = False ):
2698+ program = Program (getcwd (), True )
2699+ program .check_requirements (True )
2700+ with cd (program .path ):
2701+ tools_dir = program .get_tools ()
2702+
2703+ script = os .path .join (tools_dir , 'device_management.py' )
2704+ if not os .path .exists (script ):
2705+ error ('device management is not supported by this version of Mbed OS. Please upgrade.' )
2706+
2707+
2708+ target = target or program .get_cfg ("TARGET" )
2709+ toolchain = toolchain or program .get_cfg ("TOOLCHAIN" )
2710+
2711+ if build :
2712+ build_path = build
2713+ elif not build and target and toolchain :
2714+ build_path = os .path .join (
2715+ os .path .relpath (program .path , orig_path ),
2716+ program .build_dir ,
2717+ target .upper (),
2718+ toolchain .upper ()
2719+ )
2720+ build_path = _safe_append_profile_to_build_path (build_path , profile )
2721+ else :
2722+ build_path = None
2723+
2724+ popen ([python_cmd , '-u' , script ]
2725+ + (['-t' , toolchain ] if toolchain else [])
2726+ + (['-m' , target ] if target else [])
2727+ + (['--build' , build_path ] if build_path else [])
2728+ + remainder ,
2729+ env = program .get_env ())
2730+
26882731# Export command
26892732@subcommand ('export' ,
26902733 dict (name = ['-i' , '--ide' ], help = 'IDE to create project files for. Example: UVISION4, UVISION5, GCC_ARM, IAR, COIDE' ),
0 commit comments