The musician, who appeared in court under his real name Momodou Jallow, apologised and said he regretted his “utterly stupid” actions.
The rapper won best song at the MOBO Awards in 2017 and was nominated for the Mercury Music Prize the same year.Jallow, 23, was carrying the folding knife near Westfield in Stratford, east London, on 21 June.
He initially pleaded not guilty to possession of a blade in a public place but changed his plea at a further hearing in October.
Snaresbrook Crown Court heard he has six convictions for 10 offences.Judge Sheelagh Canavan told him: “You are role model to many, yet you have failed to leave your past behind you.”
She added: “This, in such a young life, is the fourth occasion when you have gone out armed in public with a knife.”
In a letter read to the court by his barrister Henry Blaxland QC, the rapper said: “My decision to carry a weapon was careless, ill-advised and utterly stupid.
“Being a public figure that many look up to, I simply should have known better.”
He said he had not been in his “right state of mind” and spoke of the effect the stabbing of a close friend days earlier had had on him.
He added: “I am in no way trying to justify my actions as they are unjustifiable.
“I am deeply sorry, I regret my foolish actions.”
Jallow had been sitting in his Audi with a female at the wheel and another passenger when they were stopped by police outside the Westfield centre.